Created
December 5, 2018 21:30
-
-
Save kmikulski/58419a21d5b5eea68cd481fc55dee79c to your computer and use it in GitHub Desktop.
the description for this gist
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
def verifyToken(token: String): Future[Option[AccessToken]] = { | |
val tokenVerifier = RSATokenVerifier.create(token).realmUrl(keycloakDeployment.getRealmInfoUrl) | |
for { | |
publicKey <- publicKeys.map(_.get(tokenVerifier.getHeader.getKeyId)) | |
} yield publicKey match { | |
case Some(publicKey) => | |
val token = tokenVerifier.publicKey(publicKey).verify().getToken | |
Some(token) | |
case None => | |
log.warning(s"no public key found for id ${tokenVerifier.getHeader.getKeyId}") | |
None | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment