Razvan
11/23/2020, 5:40 PMsecurity
definition of a ContractRoute or have do be done apart ?constructor(key: RequestContextLens<Any>, lookup: (String) -> Any?, name: String = "bearerAuth")
But the problem I got with that is that it requires a <Any>
if I try to use a lens: val credentials = RequestContextKey.required<Credentials>(contexts)
I get a:
Type mismatch.
Required:
RequestContextLens<Any> /* = BiDiLens<Request, Any> */
Found:
RequestContextLens<Credentials> /* = BiDiLens<Request, Credentials> */
Declaring the Lens as Any
and then doing an as
when using the Lens works.
val credentials = RequestContextKey.required<Any>(contexts)
...
val handler: HttpHandler = { request ->
val user = credentials(request) as? Credentials
...
}
...
meta {
...
security = BearerAuthSecurity(key = credentials, User::fromJwtClaims)
...
}
dave
11/23/2020, 8:07 PM