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
11542596
Commit
11542596
authored
1 year ago
by
Oded Ben-Ozer
Browse files
Options
Downloads
Patches
Plain Diff
Address issues raised in review:
Improve naming Signed-off-by:
Oded Ben-Ozer
<
obenozer@wayfair.com
>
parent
033717a0
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
connector/oidc/oidc.go
+9
-9
9 additions, 9 deletions
connector/oidc/oidc.go
connector/oidc/oidc_test.go
+8
-8
8 additions, 8 deletions
connector/oidc/oidc_test.go
with
17 additions
and
17 deletions
connector/oidc/oidc.go
+
9
−
9
View file @
11542596
...
@@ -88,16 +88,16 @@ type Config struct {
...
@@ -88,16 +88,16 @@ type Config struct {
GroupsKey
string
`json:"groups"`
// defaults to "groups"
GroupsKey
string
`json:"groups"`
// defaults to "groups"
}
`json:"claimMapping"`
}
`json:"claimMapping"`
// ClaimM
odific
ations holds all claim m
odific
ations options
// ClaimM
ut
ations holds all claim m
ut
ations options
ClaimM
odific
ations
struct
{
ClaimM
ut
ations
struct
{
NewGroup
s
FromClaims
[]
NewGroup
s
FromClaims
`json:"newGroup
s
FromClaims"`
NewGroupFromClaims
[]
NewGroupFromClaims
`json:"newGroupFromClaims"`
}
`json:"claimModifications"`
}
`json:"claimModifications"`
}
}
// NewGroupFromClaims creates a new group from a list of claims and appends it to the list of existing groups.
// NewGroupFromClaims creates a new group from a list of claims and appends it to the list of existing groups.
type
NewGroup
s
FromClaims
struct
{
type
NewGroupFromClaims
struct
{
// List of claim to join together
// List of claim to join together
Claim
List
[]
string
`json:"claim
List
"`
Claim
s
[]
string
`json:"claim
s
"`
// String to separate the claims
// String to separate the claims
Delimiter
string
`json:"delimiter"`
Delimiter
string
`json:"delimiter"`
...
@@ -210,7 +210,7 @@ func (c *Config) Open(id string, logger log.Logger) (conn connector.Connector, e
...
@@ -210,7 +210,7 @@ func (c *Config) Open(id string, logger log.Logger) (conn connector.Connector, e
preferredUsernameKey
:
c
.
ClaimMapping
.
PreferredUsernameKey
,
preferredUsernameKey
:
c
.
ClaimMapping
.
PreferredUsernameKey
,
emailKey
:
c
.
ClaimMapping
.
EmailKey
,
emailKey
:
c
.
ClaimMapping
.
EmailKey
,
groupsKey
:
c
.
ClaimMapping
.
GroupsKey
,
groupsKey
:
c
.
ClaimMapping
.
GroupsKey
,
newGroup
s
FromClaims
:
c
.
ClaimM
odific
ations
.
NewGroup
s
FromClaims
,
newGroupFromClaims
:
c
.
ClaimM
ut
ations
.
NewGroupFromClaims
,
},
nil
},
nil
}
}
...
@@ -238,7 +238,7 @@ type oidcConnector struct {
...
@@ -238,7 +238,7 @@ type oidcConnector struct {
preferredUsernameKey
string
preferredUsernameKey
string
emailKey
string
emailKey
string
groupsKey
string
groupsKey
string
newGroup
s
FromClaims
[]
NewGroup
s
FromClaims
newGroupFromClaims
[]
NewGroupFromClaims
}
}
func
(
c
*
oidcConnector
)
Close
()
error
{
func
(
c
*
oidcConnector
)
Close
()
error
{
...
@@ -450,11 +450,11 @@ func (c *oidcConnector) createIdentity(ctx context.Context, identity connector.I
...
@@ -450,11 +450,11 @@ func (c *oidcConnector) createIdentity(ctx context.Context, identity connector.I
}
}
}
}
for
_
,
config
:=
range
c
.
newGroup
s
FromClaims
{
for
_
,
config
:=
range
c
.
newGroupFromClaims
{
newGroupSegments
:=
[]
string
{
newGroupSegments
:=
[]
string
{
config
.
Prefix
,
config
.
Prefix
,
}
}
for
_
,
claimName
:=
range
config
.
Claim
List
{
for
_
,
claimName
:=
range
config
.
Claim
s
{
claimValue
,
ok
:=
claims
[
claimName
]
.
(
string
)
claimValue
,
ok
:=
claims
[
claimName
]
.
(
string
)
if
!
ok
{
// Non string claim value are ignored, concatenating them doesn't really make any sense
if
!
ok
{
// Non string claim value are ignored, concatenating them doesn't really make any sense
continue
continue
...
...
This diff is collapsed.
Click to expand it.
connector/oidc/oidc_test.go
+
8
−
8
View file @
11542596
...
@@ -62,7 +62,7 @@ func TestHandleCallback(t *testing.T) {
...
@@ -62,7 +62,7 @@ func TestHandleCallback(t *testing.T) {
expectPreferredUsername
string
expectPreferredUsername
string
expectedEmailField
string
expectedEmailField
string
token
map
[
string
]
interface
{}
token
map
[
string
]
interface
{}
newGroup
s
FromClaims
[]
NewGroup
s
FromClaims
newGroupFromClaims
[]
NewGroupFromClaims
}{
}{
{
{
name
:
"simpleCase"
,
name
:
"simpleCase"
,
...
@@ -297,9 +297,9 @@ func TestHandleCallback(t *testing.T) {
...
@@ -297,9 +297,9 @@ func TestHandleCallback(t *testing.T) {
expectUserName
:
"namevalue"
,
expectUserName
:
"namevalue"
,
expectGroups
:
[]
string
{
"group1"
,
"gh::acme::pipeline-one"
,
"clr_delim-acme-foobar"
,
"keep_delim-acme-foo-bar"
,
"bk-emailvalue"
},
expectGroups
:
[]
string
{
"group1"
,
"gh::acme::pipeline-one"
,
"clr_delim-acme-foobar"
,
"keep_delim-acme-foo-bar"
,
"bk-emailvalue"
},
expectedEmailField
:
"emailvalue"
,
expectedEmailField
:
"emailvalue"
,
newGroup
s
FromClaims
:
[]
NewGroup
s
FromClaims
{
newGroupFromClaims
:
[]
NewGroupFromClaims
{
{
// The basic functionality, should create "gh::acme::pipeline-one".
{
// The basic functionality, should create "gh::acme::pipeline-one".
Claim
List
:
[]
string
{
Claim
s
:
[]
string
{
"organization"
,
"organization"
,
"pipeline"
,
"pipeline"
,
},
},
...
@@ -307,7 +307,7 @@ func TestHandleCallback(t *testing.T) {
...
@@ -307,7 +307,7 @@ func TestHandleCallback(t *testing.T) {
Prefix
:
"gh"
,
Prefix
:
"gh"
,
},
},
{
// Non existing claims, should not generate any any new group claim.
{
// Non existing claims, should not generate any any new group claim.
Claim
List
:
[]
string
{
Claim
s
:
[]
string
{
"non-existing1"
,
"non-existing1"
,
"non-existing2"
,
"non-existing2"
,
},
},
...
@@ -317,7 +317,7 @@ func TestHandleCallback(t *testing.T) {
...
@@ -317,7 +317,7 @@ func TestHandleCallback(t *testing.T) {
{
// In this case the delimiter character("-") should be removed removed from "claim-with-delimiter" claim to ensure the resulting
{
// In this case the delimiter character("-") should be removed removed from "claim-with-delimiter" claim to ensure the resulting
// claim structure is in full control of the Dex operator and not the person creating a new pipeline.
// claim structure is in full control of the Dex operator and not the person creating a new pipeline.
// Should create "clr_delim-acme-foobar" and not "tfe-acme-foo-bar".
// Should create "clr_delim-acme-foobar" and not "tfe-acme-foo-bar".
Claim
List
:
[]
string
{
Claim
s
:
[]
string
{
"organization"
,
"organization"
,
"claim-with-delimiter"
,
"claim-with-delimiter"
,
},
},
...
@@ -327,7 +327,7 @@ func TestHandleCallback(t *testing.T) {
...
@@ -327,7 +327,7 @@ func TestHandleCallback(t *testing.T) {
},
},
{
// In this case the delimiter character("-") should be NOT removed from "claim-with-delimiter" claim.
{
// In this case the delimiter character("-") should be NOT removed from "claim-with-delimiter" claim.
// Should create "keep_delim-acme-foo-bar".
// Should create "keep_delim-acme-foo-bar".
Claim
List
:
[]
string
{
Claim
s
:
[]
string
{
"organization"
,
"organization"
,
"claim-with-delimiter"
,
"claim-with-delimiter"
,
},
},
...
@@ -336,7 +336,7 @@ func TestHandleCallback(t *testing.T) {
...
@@ -336,7 +336,7 @@ func TestHandleCallback(t *testing.T) {
Prefix
:
"keep_delim"
,
Prefix
:
"keep_delim"
,
},
},
{
// Ignore non string claims (like arrays), this should result in "bk-emailvalue".
{
// Ignore non string claims (like arrays), this should result in "bk-emailvalue".
Claim
List
:
[]
string
{
Claim
s
:
[]
string
{
"non-string-claim"
,
"non-string-claim"
,
"non-string-claim2"
,
"non-string-claim2"
,
"email"
,
"email"
,
...
@@ -397,7 +397,7 @@ func TestHandleCallback(t *testing.T) {
...
@@ -397,7 +397,7 @@ func TestHandleCallback(t *testing.T) {
config
.
ClaimMapping
.
PreferredUsernameKey
=
tc
.
preferredUsernameKey
config
.
ClaimMapping
.
PreferredUsernameKey
=
tc
.
preferredUsernameKey
config
.
ClaimMapping
.
EmailKey
=
tc
.
emailKey
config
.
ClaimMapping
.
EmailKey
=
tc
.
emailKey
config
.
ClaimMapping
.
GroupsKey
=
tc
.
groupsKey
config
.
ClaimMapping
.
GroupsKey
=
tc
.
groupsKey
config
.
ClaimM
odific
ations
.
NewGroup
s
FromClaims
=
tc
.
newGroup
s
FromClaims
config
.
ClaimM
ut
ations
.
NewGroupFromClaims
=
tc
.
newGroupFromClaims
conn
,
err
:=
newConnector
(
config
)
conn
,
err
:=
newConnector
(
config
)
if
err
!=
nil
{
if
err
!=
nil
{
...
...
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