Skip to content
Snippets Groups Projects
Verified Commit 058280df authored by Thomas SAUVAGE's avatar Thomas SAUVAGE
Browse files

Doc

parent bb56ee87
No related branches found
No related tags found
1 merge request!4Trying to implement openid
Pipeline #13847 passed
......@@ -28,15 +28,17 @@ export const loginSigmaUser = async ({ response }: HttpContextContract) => {
const issuer = await Issuer.discover(AUTH_URL)
const client = new issuer.Client(clientOptions)
// Generate and store a codeVerifier,
// Generate state and codeVerifier,
// used in the callback to verify the integrity of the request
const state = generators.state()
const codeVerifier = generators.codeVerifier()
// Store the codeVerifier in the DB
AuthCodeVerifier.create({ state, codeVerifier })
const codeChallenge = generators.codeChallenge(codeVerifier)
// Generate the url
const codeChallenge = generators.codeChallenge(codeVerifier)
const url = client.authorizationUrl({
scope: 'openid email profile groups', // What info we want about the user
code_challenge: codeChallenge,
......@@ -93,5 +95,6 @@ export const callbackSigmaUser = async ({ response, request, auth }: HttpContext
// Generate token using Adonis JS default auth provider
const token = await auth.use('api').login(user)
// TODO: Redirect to the frontend with the token ?
return response.ok({ token, user })
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment