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
8b939663
Unverified
Commit
8b939663
authored
5 months ago
by
Melroy Dsouza
Committed by
GitHub
5 months ago
Browse files
Options
Downloads
Patches
Plain Diff
Support for IssuerAlias and groups as maps (#3676)
Signed-off-by:
Melroy Dsouza
<
meldsza@gmail.com
>
parent
d02035f8
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
connector/oidc/oidc.go
+16
-2
16 additions, 2 deletions
connector/oidc/oidc.go
connector/oidc/oidc_test.go
+49
-0
49 additions, 0 deletions
connector/oidc/oidc_test.go
with
65 additions
and
2 deletions
connector/oidc/oidc.go
+
16
−
2
View file @
8b939663
...
...
@@ -23,7 +23,12 @@ import (
// Config holds configuration options for OpenID Connect logins.
type
Config
struct
{
Issuer
string
`json:"issuer"`
Issuer
string
`json:"issuer"`
// Some offspec providers like Azure, Oracle IDCS have oidc discovery url
// different from issuer url which causes issuerValidation to fail
// IssuerAlias provides a way to override the Issuer url
// from the .well-known/openid-configuration issuer
IssuerAlias
string
`json:"issuerAlias"`
ClientID
string
`json:"clientID"`
ClientSecret
string
`json:"clientSecret"`
RedirectURI
string
`json:"redirectURI"`
...
...
@@ -226,7 +231,9 @@ func (c *Config) Open(id string, logger *slog.Logger) (conn connector.Connector,
bgctx
,
cancel
:=
context
.
WithCancel
(
context
.
Background
())
ctx
:=
context
.
WithValue
(
bgctx
,
oauth2
.
HTTPClient
,
httpClient
)
if
c
.
IssuerAlias
!=
""
{
ctx
=
oidc
.
InsecureIssuerURLContext
(
ctx
,
c
.
IssuerAlias
)
}
provider
,
err
:=
getProvider
(
ctx
,
c
.
Issuer
,
c
.
ProviderDiscoveryOverrides
)
if
err
!=
nil
{
cancel
()
...
...
@@ -540,6 +547,13 @@ func (c *oidcConnector) createIdentity(ctx context.Context, identity connector.I
continue
}
groups
=
append
(
groups
,
s
)
}
else
if
groupMap
,
ok
:=
v
.
(
map
[
string
]
interface
{});
ok
{
if
s
,
ok
:=
groupMap
[
"name"
]
.
(
string
);
ok
{
if
c
.
groupsFilter
!=
nil
&&
!
c
.
groupsFilter
.
MatchString
(
s
)
{
continue
}
groups
=
append
(
groups
,
s
)
}
}
else
{
return
identity
,
fmt
.
Errorf
(
"malformed
\"
%v
\"
claim"
,
groupsKey
)
}
...
...
This diff is collapsed.
Click to expand it.
connector/oidc/oidc_test.go
+
49
−
0
View file @
8b939663
...
...
@@ -292,6 +292,38 @@ func TestHandleCallback(t *testing.T) {
"email_verified"
:
true
,
},
},
{
name
:
"singularGroupResponseAsMap"
,
userIDKey
:
""
,
// not configured
userNameKey
:
""
,
// not configured
expectUserID
:
"subvalue"
,
expectUserName
:
"namevalue"
,
expectGroups
:
[]
string
{
"group1"
},
expectedEmailField
:
"emailvalue"
,
token
:
map
[
string
]
interface
{}{
"sub"
:
"subvalue"
,
"name"
:
"namevalue"
,
"groups"
:
[]
map
[
string
]
string
{{
"name"
:
"group1"
}},
"email"
:
"emailvalue"
,
"email_verified"
:
true
,
},
},
{
name
:
"multipleGroupResponseAsMap"
,
userIDKey
:
""
,
// not configured
userNameKey
:
""
,
// not configured
expectUserID
:
"subvalue"
,
expectUserName
:
"namevalue"
,
expectGroups
:
[]
string
{
"group1"
,
"group2"
},
expectedEmailField
:
"emailvalue"
,
token
:
map
[
string
]
interface
{}{
"sub"
:
"subvalue"
,
"name"
:
"namevalue"
,
"groups"
:
[]
map
[
string
]
string
{{
"name"
:
"group1"
},
{
"name"
:
"group2"
}},
"email"
:
"emailvalue"
,
"email_verified"
:
true
,
},
},
{
name
:
"newGroupFromClaims"
,
userIDKey
:
""
,
// not configured
...
...
@@ -382,6 +414,23 @@ func TestHandleCallback(t *testing.T) {
"email_verified"
:
true
,
},
},
{
name
:
"filterGroupClaimsMap"
,
userIDKey
:
""
,
// not configured
userNameKey
:
""
,
// not configured
groupsRegex
:
`^.*\d$`
,
expectUserID
:
"subvalue"
,
expectUserName
:
"namevalue"
,
expectGroups
:
[]
string
{
"group1"
,
"group2"
},
expectedEmailField
:
"emailvalue"
,
token
:
map
[
string
]
interface
{}{
"sub"
:
"subvalue"
,
"name"
:
"namevalue"
,
"groups"
:
[]
map
[
string
]
string
{{
"name"
:
"group1"
},
{
"name"
:
"group2"
},
{
"name"
:
"groupA"
},
{
"name"
:
"groupB"
}},
"email"
:
"emailvalue"
,
"email_verified"
:
true
,
},
},
}
for
_
,
tc
:=
range
tests
{
...
...
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