-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add ticket context in order to store mfa information like mfa channel…
… and mfa method
- Loading branch information
Showing
8 changed files
with
69 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
src/main/kotlin/com/vauthenticator/server/extentions/MapExt.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.vauthenticator.server.extentions | ||
|
||
import software.amazon.awssdk.services.dynamodb.model.AttributeValue | ||
import java.util.* | ||
|
||
fun Map<String, String>.asDynamoAttribute(): AttributeValue = | ||
this.map { mutableMapOf(it.key to AttributeValue.builder().s(it.value).build()) } | ||
.reduce { a, b -> a.plus(b) as MutableMap<String, AttributeValue> } | ||
.let { AttributeValue.fromM(it) } | ||
|
||
fun Map<String, AttributeValue>.valueAsMapFor(key: String): Map<String, String> = | ||
Optional.ofNullable(this[key]) | ||
.map { it.m() } | ||
.map { it.entries } | ||
.map { it.map { mutableMapOf(it.key to it.value.s()) } } | ||
.map { it.reduce { acc, mutableMap -> (acc + mutableMap) as MutableMap<String, String> } } | ||
.orElseGet { mutableMapOf<String, String>() } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 17 additions & 2 deletions
19
src/test/kotlin/com/vauthenticator/server/support/TicketFixture.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,24 @@ | ||
package com.vauthenticator.server.support | ||
|
||
import com.vauthenticator.server.mfa.domain.MfaMethod | ||
import com.vauthenticator.server.ticket.Ticket | ||
import com.vauthenticator.server.ticket.TicketContext | ||
import com.vauthenticator.server.ticket.TicketId | ||
|
||
object TicketFixture { | ||
fun ticketFor(verificationTicketValue: String, mail: String, clientAppId: String) = | ||
Ticket(TicketId(verificationTicketValue), mail, clientAppId, 200) | ||
|
||
fun ticketContext(email: String) = TicketContext( | ||
mapOf( | ||
"mfaChannel" to email, | ||
"mfaMethod" to MfaMethod.EMAIL_MFA_METHOD.name | ||
) | ||
) | ||
|
||
fun ticketFor(verificationTicketValue: String, email: String, clientAppId: String): Ticket { | ||
|
||
return Ticket( | ||
TicketId(verificationTicketValue), email, clientAppId, 200, | ||
ticketContext(email) | ||
) | ||
} | ||
} |