Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sso_proxy: allow empty slice of groups #289

Merged
merged 2 commits into from
Mar 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions internal/proxy/providers/sso.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,9 @@ func (p *SSOProvider) ValidateGroup(email string, allowedGroups []string, access

logger.WithUser(email).WithAllowedGroups(allowedGroups).Info("validating groups")
inGroups := []string{}
if len(allowedGroups) == 0 || len(allowedGroups) == 1 && allowedGroups[0] == "*" {
return inGroups, true, nil
}

userGroups, err := p.UserGroups(email, allowedGroups, accessToken)
if err != nil {
Expand Down
28 changes: 24 additions & 4 deletions internal/proxy/providers/sso_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,20 @@ func TestSSOProviderGroups(t *testing.T) {
ProfileStatus int
}{
{
Name: "invalid when no group id set",
Name: "valid when no group id set",
Email: "michael.bland@gsa.gov",
Groups: []string{},
ProxyGroupIds: []string{},
ExpectedValid: false,
ExpectedValid: true,
ExpectedInGroups: []string{},
ExpectError: nil,
},
{
Name: "valid when group list consists of a single wildcard",
Email: "michael.bland@gsa.gov",
Groups: []string{},
ProxyGroupIds: []string{"*"},
ExpectedValid: true,
ExpectedInGroups: []string{},
ExpectError: nil,
},
Expand Down Expand Up @@ -311,15 +320,26 @@ func TestSSOProviderValidateSessionState(t *testing.T) {
ExpectedValid bool
}{
{
Name: "invalid when no group id set",
Name: "valid when no group id set",
SessionState: &sessions.SessionState{
AccessToken: "abc",
Email: "michael.bland@gsa.gov",
},
ProviderResponse: http.StatusOK,
Groups: []string{},
ProxyGroupIds: []string{},
ExpectedValid: false,
ExpectedValid: true,
},
{
Name: "valid when group list consists of single wildcard",
SessionState: &sessions.SessionState{
AccessToken: "abc",
Email: "michael.bland@gsa.gov",
},
ProviderResponse: http.StatusOK,
Groups: []string{},
ProxyGroupIds: []string{"*"},
ExpectedValid: true,
},
{
Name: "invalid when response is is not 200",
Expand Down