kotlin-oauth2-server icon indicating copy to clipboard operation
kotlin-oauth2-server copied to clipboard

Form login authorize endpoint

Open adhesivee opened this issue 5 years ago • 3 comments

Last changes allow to create form login on authorization endpoint. It might be unclear how to do it. This could be added to documentation.

adhesivee avatar Jun 27 '19 12:06 adhesivee

yeah. It's totally not clear, how to do this. Anything new on the documentation?

MaaxGr avatar Mar 19 '21 15:03 MaaxGr

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.

Schpammer avatar Jan 30 '22 10:01 Schpammer

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

adhesivee avatar Feb 19 '22 21:02 adhesivee