Can we return UserIdPrincipal(credentials.password) instead of UserIdPrincipal(credentials.name) in the validate function?
install(Authentication) {
basic("myAuth") {
realm = "Access to the '/page' path"
validate { credentials ->
if (credentials.name == "Admin" && credentials.password == "2425") {
UserIdPrincipal(credentials.password)
} else {
null
}
}
}
}
routing {
authenticate("myAuth") {
get("/page") {
call.respondText("Protected content! Name: ${call.principal<UserIdPrincipal>()?.name}")
}
}
}
You can open the IDE and check the result yourself.