hellman
03/03/2025, 5:06 PMcall
in my Ktor server. Anyone know how I can do that? I got the Authentication
installed and jwt()
setup, so I can wrap my endpoint with authenticate { }
, but now I need to take the accessToken and pass it on to a different service (not HTTP).Aleksei Tirman [JB]
03/04/2025, 12:29 PMget {
val jwt = JWT
.require(Algorithm.HMAC256("secret"))
.withAudience("audience")
.withIssuer("issuer")
.build()
val auth = call.request.headers[HttpHeaders.Authorization] ?: return@get
val authHeader = parseAuthorizationHeader(auth)
if (authHeader is HttpAuthHeader.Single) {
val decodedJWT = jwt.verify(authHeader.blob)
}
}
hellman
03/04/2025, 12:30 PMcall.principal()
Tian Tian098
03/04/2025, 10:19 PMinstall(Authentication) {
bearer {
authenticate { (token) ->
// Parse the JWT and return something
}
}
hellman
03/05/2025, 5:01 AMAleksei Tirman [JB]
03/05/2025, 8:20 AMhellman
03/05/2025, 8:34 AMfun Headers.getAccessToken() = this["Authorization"]?.removePrefix("Bearer ")
It works, and I'm fine if this is what I have to use.
The reason I need this is to propagate the JWT when I call other services.