Skip to content

Commit

Permalink
add the correct client id into the ticket
Browse files Browse the repository at this point in the history
  • Loading branch information
mrFlick72 committed Jul 27, 2024
1 parent 7c6cdc8 commit ba6533c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,19 @@ package com.vauthenticator.server.extentions
import com.vauthenticator.server.oauth2.clientapp.ClientAppId
import com.vauthenticator.server.oauth2.clientapp.Scope
import com.vauthenticator.server.oauth2.clientapp.Scopes
import org.springframework.security.core.Authentication
import org.springframework.security.oauth2.server.resource.authentication.JwtAuthenticationToken

fun Authentication.clientAppId(): ClientAppId {
val authentication = this as JwtAuthenticationToken
return authentication.clientAppId()
}

fun JwtAuthenticationToken.clientAppId(): ClientAppId {
val aud = this.token.claims["aud"]!!
return try {
ClientAppId((aud as String))
} catch (e : RuntimeException){
} catch (e: RuntimeException) {
ClientAppId((aud as List<String>)[0])
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package com.vauthenticator.server.mfa.api

import com.vauthenticator.server.account.repository.AccountRepository
import com.vauthenticator.server.extentions.clientAppId
import com.vauthenticator.server.mask.SensitiveEmailMasker
import com.vauthenticator.server.mfa.domain.EmailMfaDevice
import com.vauthenticator.server.mfa.domain.MfaMethod
import com.vauthenticator.server.mfa.domain.MfaMethodsEnrollment
import com.vauthenticator.server.mfa.domain.MfaMethodsEnrollmentAssociation
import com.vauthenticator.server.mfa.repository.MfaAccountMethodsRepository
import com.vauthenticator.server.oauth2.clientapp.ClientAppId
import org.springframework.http.ResponseEntity
import org.springframework.http.ResponseEntity.ok
import org.springframework.security.core.Authentication
Expand Down Expand Up @@ -54,7 +54,7 @@ class MfaEnrolmentAssociationEndPoint(
authentication.name,
enrolling.mfaMethod,
enrolling.mfaChannel,
ClientAppId.empty(), //todo figure out how to detect the client app
authentication.clientAppId(),
true
)
return ok(ticketId.content)
Expand Down

0 comments on commit ba6533c

Please sign in to comment.