Open adhesivee opened 5 years ago
yeah. It's totally not clear, how to do this. Anything new on the documentation?
Hey! Are there any plans to add this to the documentation any time soon? I really like the simplicity of this lib but a form login is a must have in my usecase.
Still have to put some effort into this. Each framework has a special callback configuration for this, example: Javalin Ktor
Configuration can be done something like:
identityService = InMemoryIdentity()
.identity {
username = "foo"
password = "bar"
}
clientService = InMemoryClient()
.client {
clientId = "testapp"
clientSecret = "testpass"
scopes = setOf("trusted")
redirectUris = setOf("https://localhost:7000/callback")
authorizedGrantTypes = setOf(
AuthorizedGrantType.AUTHORIZATION_CODE,
AuthorizedGrantType.PASSWORD,
AuthorizedGrantType.IMPLICIT,
AuthorizedGrantType.REFRESH_TOKEN
)
}
tokenStore = InMemoryTokenStore()
authenticationCallback = { call, callRouter ->
if (authenticated) {
val context = KtorCallContext(call)
CallContextBasicAuthenticator.handleAuthentication(context, callRouter)
} else {
// render login page
}
}
call
in the callback will always be the context of the framework. So for Ktor this will be ApplicationCall
and for Javalin this will be Context
to give you full control over the request.
It will invoke this callback for POST
and GET
Last changes allow to create form login on authorization endpoint. It might be unclear how to do it. This could be added to documentation.