Created
November 12, 2018 00:21
-
-
Save Hades32/a84eca1473544641dd312f18134f6c1b to your computer and use it in GitHub Desktop.
Handling JWT Validation with only RSA X.509 Public Key
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
package mn.max | |
import io.micronaut.context.annotation.Value | |
import io.micronaut.security.token.jwt.signature.rsa.RSASignatureConfiguration | |
import java.security.KeyFactory | |
import java.security.interfaces.RSAPublicKey | |
import java.security.spec.X509EncodedKeySpec | |
import java.util.* | |
import javax.inject.Named | |
import javax.inject.Singleton | |
@Singleton | |
@Named("validation") | |
class JwtSecurityConfig : RSASignatureConfiguration { | |
@Value("\${jwt-config.key:MISSING_KEY}") | |
var key = "TODO" | |
override fun getPublicKey(): RSAPublicKey { | |
val publicKey = KeyFactory.getInstance("RSA") | |
.generatePublic(X509EncodedKeySpec(Base64.getDecoder().decode(key))) | |
return publicKey as RSAPublicKey | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment