Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
Example backend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Thomas SAUVAGE
Example backend
Commits
058280df
Verified
Commit
058280df
authored
1 year ago
by
Thomas SAUVAGE
Browse files
Options
Downloads
Patches
Plain Diff
Doc
parent
bb56ee87
No related branches found
No related tags found
1 merge request
!4
Trying to implement openid
Pipeline
#13847
passed
1 year ago
Stage: Code quality
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
app/Controllers/auth/authSigmaUser.ts
+5
-2
5 additions, 2 deletions
app/Controllers/auth/authSigmaUser.ts
with
5 additions
and
2 deletions
app/Controllers/auth/authSigmaUser.ts
+
5
−
2
View file @
058280df
...
...
@@ -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 stor
e a codeVerifier,
// Generate
stat
e a
nd
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
})
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment