Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Form login authorize endpoint #67

Open
adhesivee opened this issue Jun 27, 2019 · 3 comments
Open

Form login authorize endpoint #67

adhesivee opened this issue Jun 27, 2019 · 3 comments

Comments

@adhesivee
Copy link
Collaborator

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

@MaaxGr
Copy link

MaaxGr commented Mar 19, 2021

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

@Schpammer
Copy link

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.

@adhesivee
Copy link
Collaborator Author

adhesivee commented Feb 19, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants