Skip to content

Commit

Permalink
Password method tested
Browse files Browse the repository at this point in the history
  • Loading branch information
UnknownJoe796 committed Oct 9, 2023
1 parent d32cc39 commit 6eeb037
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions demo/src/main/kotlin/Server.kt
Original file line number Diff line number Diff line change
Expand Up @@ -251,13 +251,14 @@ object Server : ServerPathGroup(ServerPath.root) {
)
})
val proofOtp = OneTimePasswordProofEndpoints(path("proof/otp"), database, cache)
val proofPassword = PasswordProofEndpoints(path("proof/password"), database, cache)
val subjects = AuthEndpointsForSubject(
path("subject"),
object : Authentication.SubjectHandler<User, UUID> {
override val name: String get() = "User"
override val idProofs: Set<Authentication.ProofMethod> = setOf(proofEmail)
override val authType: AuthType get() = AuthType<User>()
override val additionalProofs: Set<Authentication.ProofMethod> = setOf(proofOtp)
override val additionalProofs: Set<Authentication.ProofMethod> = setOf(proofOtp, proofPassword)
override suspend fun authenticate(vararg proofs: Proof): Authentication.AuthenticateResult<User, UUID>? {
val emailIdentifier = proofs.find { it.of == "email" } ?: return null
val user = userInfo.collection().findOne(condition { it.email eq emailIdentifier.value }) ?: run {
Expand All @@ -270,12 +271,13 @@ object Server : ServerPathGroup(ServerPath.root) {
val options = listOfNotNull(
ProofOption(proofEmail.info, user.email),
proofOtp.proofOption(this, user._id),
proofPassword.proofOption(this, user._id),
)
return Authentication.AuthenticateResult(
id = user._id,
subjectCopy = user,
options = options,
strengthRequired = 15
strengthRequired = 20
)
}

Expand Down

0 comments on commit 6eeb037

Please sign in to comment.