Skip to content
Snippets Groups Projects
Unverified Commit 72dd3c60 authored by Joost Buskermolen's avatar Joost Buskermolen Committed by GitHub
Browse files

fix: Fallback when group claim is a string instead of an array of strings (#2639)

parent f90318ea
No related branches found
No related tags found
No related merge requests found
......@@ -351,6 +351,11 @@ func (c *oidcConnector) createIdentity(ctx context.Context, identity connector.I
vs, found = claims[groupsKey].([]interface{})
}
// Fallback when claims[groupsKey] is a string instead of an array of strings.
if g, b := claims[groupsKey].(string); b {
groups = []string{g}
}
if found {
for _, v := range vs {
if s, ok := v.(string); ok {
......
......@@ -271,6 +271,22 @@ func TestHandleCallback(t *testing.T) {
"cognito:groups": []string{"group3", "group4"},
},
},
{
name: "singularGroupResponseAsString",
userIDKey: "", // not configured
userNameKey: "", // not configured
expectUserID: "subvalue",
expectUserName: "namevalue",
expectGroups: []string{"group1"},
expectedEmailField: "emailvalue",
token: map[string]interface{}{
"sub": "subvalue",
"name": "namevalue",
"groups": "group1",
"email": "emailvalue",
"email_verified": true,
},
},
}
for _, tc := range tests {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment