bram93
09/04/2019, 11:02 AMUriel Salischiker
09/04/2019, 11:05 AMbram93
09/04/2019, 11:17 AMUriel Salischiker
09/04/2019, 11:24 AMbram93
09/04/2019, 11:58 AMvalidate
function:
install(Authentication) {
jwt {
verifier(jwkProvider, jwkIssuer)
realm = jwkRealm
validate { credentials ->
if (credentials.payload.audience.contains(jwkAudience)) {
val account = httpClient.get<Account>(accountEndpoint) {
header("Authorization", request.header("Authorization"))
}
KKPrincipal(credentials.payload, account)
} else null
}
}
}
Sergey Akhapkin
09/04/2019, 6:14 PMinstall(Sessions) {
cookie<CookieClass>("CookieName") {
// configure cookie provider: path, httpOnly, secure and so on
}
}
install(Authentication) {
session<CookieClass>("AuthorizationName") {
challenge {
appendWWWAuthenticateHeader(call)
call.respond(HttpStatusCode.Unauthorized)
}
validate {
// it here points to you CookieClass - extract data and may be call db to find user
}
}
}
Uriel Salischiker
09/04/2019, 7:03 PMSergey Akhapkin
09/04/2019, 7:43 PMfun CookieSessionBuilder<CookieClass>.init() {
...
serializer = object : SessionSerializer {
override fun deserialize(text: String): Any = ...
override fun serialize(session: Any): String = ...
}
}