mkporwit
07/13/2017, 8:55 PMroute(loginPath) {
authentication {
basicAuthentication("HOYLU") { credentials ->
val email = credentials.name.toLowerCase(Locale.ROOT)
val userPass = credentials.password
ldapAuth(UserEmailCredential(email, userPass))
}
}
get {
val claims = call.authentication.principal<Person>()?.let { generateClaims(it) } ?: throw RuntimeException("Error generating claims")
val jwt = generateJwt(claims)
jwtHandler.store(claims.getStringClaimValue("email"), jwt)
call.respond(JsonResponse(AuthToken(jwt)))
}
options {
call.response.headers.append("Access-Control-Allow-Origin", "*")
call.response.headers.append("Access-Control-Allow-Methods", "GET, OPTIONS")
call.response.status(HttpStatusCode.OK)
}
}