Hi everyone,
I'm trying to protect my RESTful APIs with JWT.
I created a subclass of HttpAuthentication
case classJWTAuthentication(realmName: String)(func: PartialFunction[(String, Req), Boolean]) extends HttpAuthentication{
....
override def verified_?: PartialFunction[Req, Boolean] = {
case (req) =>
//verify the JWT and extract claims
func(decoded, req)
}
}
In Boot.scala I have
LiftRules.authentication = JWTAuthentication("api"){
case(payload, _) =>
println(payload)
true
}
The problem is that in my APIs I need to access the extracted claims
serve("api" / "test" prefix {
case "protected" :: Nil JsonPost json -> req =>
//It would be cool to have the req with the decoded token, and not re decode the token on each protected endpoint
})
Is there a way to modify the request in order to augment it with the decoded jwt?
I took a look at RewriteRequest but I think It's not suitable for my use case
Thanks in advance