Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dex
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
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
Code review analytics
Issue analytics
Insights
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
hdacloud
dex
Commits
77fcf9ad
Unverified
Commit
77fcf9ad
authored
5 years ago
by
Joel Speed
Browse files
Options
Downloads
Patches
Plain Diff
Use a struct for connector data within OIDC connector
parent
f6077083
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
connector/oidc/oidc.go
+23
-2
23 additions, 2 deletions
connector/oidc/oidc.go
with
23 additions
and
2 deletions
connector/oidc/oidc.go
+
23
−
2
View file @
77fcf9ad
...
...
@@ -3,6 +3,7 @@ package oidc
import
(
"context"
"encoding/json"
"errors"
"fmt"
"net/http"
...
...
@@ -61,6 +62,11 @@ var brokenAuthHeaderDomains = []string{
"oktapreview.com"
,
}
// connectorData stores information for sessions authenticated by this connector
type
connectorData
struct
{
refreshToken
[]
byte
}
// Detect auth header provider issues for known providers. This lets users
// avoid having to explicitly set "basicAuthUnsupported" in their config.
//
...
...
@@ -210,8 +216,14 @@ func (c *oidcConnector) HandleCallback(s connector.Scopes, r *http.Request) (ide
// Refresh is used to refresh a session with the refresh token provided by the IdP
func
(
c
*
oidcConnector
)
Refresh
(
ctx
context
.
Context
,
s
connector
.
Scopes
,
identity
connector
.
Identity
)
(
connector
.
Identity
,
error
)
{
cd
:=
connectorData
{}
err
:=
json
.
Unmarshal
(
identity
.
ConnectorData
,
&
cd
)
if
err
!=
nil
{
return
identity
,
fmt
.
Errorf
(
"oidc: failed to unmarshal connector data: %v"
,
err
)
}
t
:=
&
oauth2
.
Token
{
RefreshToken
:
string
(
identity
.
ConnectorData
),
RefreshToken
:
string
(
cd
.
refreshToken
),
Expiry
:
time
.
Now
()
.
Add
(
-
time
.
Hour
),
}
token
,
err
:=
c
.
oauth2Config
.
TokenSource
(
ctx
,
t
)
.
Token
()
...
...
@@ -284,12 +296,21 @@ func (c *oidcConnector) createIdentity(ctx context.Context, identity connector.I
}
}
cd
:=
connectorData
{
refreshToken
:
[]
byte
(
token
.
RefreshToken
),
}
connData
,
err
:=
json
.
Marshal
(
&
cd
)
if
err
!=
nil
{
return
identity
,
fmt
.
Errorf
(
"oidc: failed to encode connector data: %v"
,
err
)
}
identity
=
connector
.
Identity
{
UserID
:
idToken
.
Subject
,
Username
:
name
,
Email
:
email
,
EmailVerified
:
emailVerified
,
ConnectorData
:
[]
byte
(
token
.
RefreshToken
)
,
ConnectorData
:
connData
,
}
if
c
.
userIDKey
!=
""
{
...
...
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