-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
connector/saml: add 'FilterGroups' setting
This should make AllowedGroups equivalent to an LDAP group filter: When set to true, only the groups from AllowedGroups will be included in the user's identity. Signed-off-by: Stephan Renatus <[email protected]>
- Loading branch information
Showing
3 changed files
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,6 +53,7 @@ type responseTest struct { | |
emailAttr string | ||
groupsAttr string | ||
allowedGroups []string | ||
filterGroups bool | ||
|
||
// Expected outcome of the test. | ||
wantErr bool | ||
|
@@ -121,6 +122,29 @@ func TestGroupsWhitelist(t *testing.T) { | |
test.run(t) | ||
} | ||
|
||
func TestGroupsWhitelistWithFiltering(t *testing.T) { | ||
test := responseTest{ | ||
caFile: "testdata/ca.crt", | ||
respFile: "testdata/good-resp.xml", | ||
now: "2017-04-04T04:34:59.330Z", | ||
usernameAttr: "Name", | ||
emailAttr: "email", | ||
groupsAttr: "groups", | ||
allowedGroups: []string{"Admins"}, | ||
filterGroups: true, | ||
inResponseTo: "6zmm5mguyebwvajyf2sdwwcw6m", | ||
redirectURI: "http://127.0.0.1:5556/dex/callback", | ||
wantIdent: connector.Identity{ | ||
UserID: "[email protected]", | ||
Username: "Eric", | ||
Email: "[email protected]", | ||
EmailVerified: true, | ||
Groups: []string{"Admins"}, // "Everyone" is filtered | ||
}, | ||
} | ||
test.run(t) | ||
} | ||
|
||
func TestGroupsWhitelistEmpty(t *testing.T) { | ||
test := responseTest{ | ||
caFile: "testdata/ca.crt", | ||
|
@@ -388,6 +412,7 @@ func (r responseTest) run(t *testing.T) { | |
RedirectURI: r.redirectURI, | ||
EntityIssuer: r.entityIssuer, | ||
AllowedGroups: r.allowedGroups, | ||
FilterGroups: r.filterGroups, | ||
// Never logging in, don't need this. | ||
SSOURL: "http://foo.bar/", | ||
} | ||
|