Skip to content
Snippets Groups Projects
Commit a5284841 authored by Oded Ben-Ozer's avatar Oded Ben-Ozer
Browse files

Rename configuration option to include a reference to groups

and structure for future claim modification additions

Signed-off-by: default avatarOded Ben-Ozer <obenozer@wayfair.com>
parent 088c380d
No related branches found
No related tags found
No related merge requests found
......@@ -88,12 +88,14 @@ type Config struct {
GroupsKey string `json:"groups"` // defaults to "groups"
} `json:"claimMapping"`
// List of new claim to generate based on concatinate existing claims
ClaimConcatenations []ClaimConcatenation `json:"claimConcatenations"`
// ClaimModifications holds all claim modifications options, current has only newGroupsFromClaims
ClaimModifications struct {
NewGroupsFromClaims []NewGroupsFromClaims `json:"newGroupsFromClaims"`
}
}
// List of groups claim elements to create by concatenating other claims
type ClaimConcatenation struct {
type NewGroupsFromClaims struct {
// List of claim to join together
ClaimList []string `json:"claimList"`
......@@ -204,7 +206,7 @@ func (c *Config) Open(id string, logger log.Logger) (conn connector.Connector, e
preferredUsernameKey: c.ClaimMapping.PreferredUsernameKey,
emailKey: c.ClaimMapping.EmailKey,
groupsKey: c.ClaimMapping.GroupsKey,
claimConcatenations: c.ClaimConcatenations,
newGroupsFromClaims: c.ClaimModifications.NewGroupsFromClaims,
}, nil
}
......@@ -232,7 +234,7 @@ type oidcConnector struct {
preferredUsernameKey string
emailKey string
groupsKey string
claimConcatenations []ClaimConcatenation
newGroupsFromClaims []NewGroupsFromClaims
}
func (c *oidcConnector) Close() error {
......@@ -444,7 +446,7 @@ func (c *oidcConnector) createIdentity(ctx context.Context, identity connector.I
}
}
for _, cc := range c.claimConcatenations {
for _, cc := range c.newGroupsFromClaims {
newElement := ""
for _, clm := range cc.ClaimList {
// Non string claim value are ignored, concatenating them doesn't really make any sense
......
......@@ -62,7 +62,7 @@ func TestHandleCallback(t *testing.T) {
expectPreferredUsername string
expectedEmailField string
token map[string]interface{}
claimConcatenations []ClaimConcatenation
newGroupsFromClaims []NewGroupsFromClaims
}{
{
name: "simpleCase",
......@@ -297,7 +297,7 @@ func TestHandleCallback(t *testing.T) {
expectUserName: "namevalue",
expectGroups: []string{"group1", "gh::acme::pipeline-one", "tfe-acme-foobar", "bk-emailvalue"},
expectedEmailField: "emailvalue",
claimConcatenations: []ClaimConcatenation{
newGroupsFromClaims: []NewGroupsFromClaims{
{ // The basic functionality, should create "gh::acme::pipeline-one".
ClaimList: []string{
"organization",
......@@ -382,11 +382,11 @@ func TestHandleCallback(t *testing.T) {
InsecureEnableGroups: true,
BasicAuthUnsupported: &basicAuth,
OverrideClaimMapping: tc.overrideClaimMapping,
ClaimConcatenations: tc.claimConcatenations,
}
config.ClaimMapping.PreferredUsernameKey = tc.preferredUsernameKey
config.ClaimMapping.EmailKey = tc.emailKey
config.ClaimMapping.GroupsKey = tc.groupsKey
config.ClaimModifications.NewGroupsFromClaims = tc.newGroupsFromClaims
conn, err := newConnector(config)
if err != nil {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment