From c75733d80cf57bb1a017eb384b24a602c5e38773 Mon Sep 17 00:00:00 2001 From: Justin Hines Date: Mon, 1 Apr 2019 15:52:54 -0400 Subject: [PATCH] sso_proxy: go vet --- internal/proxy/oauthproxy.go | 2 +- internal/proxy/providers/providers.go | 4 ++-- internal/proxy/providers/singleflight_middleware.go | 8 ++++---- internal/proxy/providers/sso_test.go | 2 +- internal/proxy/providers/test_provider.go | 12 ++++++------ 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/internal/proxy/oauthproxy.go b/internal/proxy/oauthproxy.go index a5cc72e9..5445f8e5 100755 --- a/internal/proxy/oauthproxy.go +++ b/internal/proxy/oauthproxy.go @@ -810,7 +810,7 @@ func (p *OAuthProxy) OAuthCallback(rw http.ResponseWriter, req *http.Request) { } allowedGroups := route.upstreamConfig.AllowedGroups - inGroups, validGroup, err := p.provider.ValidateGroup(session.Email, allowedGroups) + inGroups, validGroup, err := p.provider.ValidateGroup(session.Email, allowedGroups, session.AccessToken) if err != nil { tags = append(tags, "error:user_group_failed") p.StatsdClient.Incr("provider_error", tags, 1.0) diff --git a/internal/proxy/providers/providers.go b/internal/proxy/providers/providers.go index 9dbb6945..226dc16f 100644 --- a/internal/proxy/providers/providers.go +++ b/internal/proxy/providers/providers.go @@ -11,8 +11,8 @@ import ( type Provider interface { Data() *ProviderData Redeem(string, string) (*sessions.SessionState, error) - ValidateGroup(string, []string) ([]string, bool, error) - UserGroups(string, []string) ([]string, error) + ValidateGroup(string, []string, string) ([]string, bool, error) + UserGroups(string, []string, string) ([]string, error) ValidateSessionState(*sessions.SessionState, []string) bool GetSignInURL(redirectURL *url.URL, finalRedirect string) *url.URL GetSignOutURL(redirectURL *url.URL) *url.URL diff --git a/internal/proxy/providers/singleflight_middleware.go b/internal/proxy/providers/singleflight_middleware.go index 1fb03fd2..259f396c 100644 --- a/internal/proxy/providers/singleflight_middleware.go +++ b/internal/proxy/providers/singleflight_middleware.go @@ -71,16 +71,16 @@ func (p *SingleFlightProvider) Redeem(redirectURL, code string) (*sessions.Sessi } // ValidateGroup takes an email, allowedGroups, and userGroups and passes it to the provider's ValidateGroup function and returns the response -func (p *SingleFlightProvider) ValidateGroup(email string, allowedGroups []string) ([]string, bool, error) { - return p.provider.ValidateGroup(email, allowedGroups) +func (p *SingleFlightProvider) ValidateGroup(email string, allowedGroups []string, accessToken string) ([]string, bool, error) { + return p.provider.ValidateGroup(email, allowedGroups, accessToken) } // UserGroups takes an email and passes it to the provider's UserGroups function and returns the response -func (p *SingleFlightProvider) UserGroups(email string, groups []string) ([]string, error) { +func (p *SingleFlightProvider) UserGroups(email string, groups []string, accessToken string) ([]string, error) { // sort the groups so that other requests may be able to use the cached request sort.Strings(groups) response, err := p.do("UserGroups", fmt.Sprintf("%s:%s", email, strings.Join(groups, ",")), func() (interface{}, error) { - return p.provider.UserGroups(email, groups) + return p.provider.UserGroups(email, groups, accessToken) }) if err != nil { return nil, err diff --git a/internal/proxy/providers/sso_test.go b/internal/proxy/providers/sso_test.go index 23520b46..56cc6101 100644 --- a/internal/proxy/providers/sso_test.go +++ b/internal/proxy/providers/sso_test.go @@ -199,7 +199,7 @@ func TestSSOProviderGroups(t *testing.T) { } p.ProfileURL, server = newTestServer(profileStatus, body) defer server.Close() - inGroups, valid, err := p.ValidateGroup(tc.Email, tc.ProxyGroupIds) + inGroups, valid, err := p.ValidateGroup(tc.Email, tc.ProxyGroupIds, "accessToken") testutil.Equal(t, tc.ExpectError, err) if err == nil { testutil.Equal(t, tc.ExpectedValid, valid) diff --git a/internal/proxy/providers/test_provider.go b/internal/proxy/providers/test_provider.go index 71ac1d5f..dbf2176b 100644 --- a/internal/proxy/providers/test_provider.go +++ b/internal/proxy/providers/test_provider.go @@ -11,8 +11,8 @@ type TestProvider struct { RefreshSessionFunc func(*sessions.SessionState, []string) (bool, error) ValidateSessionFunc func(*sessions.SessionState, []string) bool RedeemFunc func(string, string) (*sessions.SessionState, error) - UserGroupsFunc func(string, []string) ([]string, error) - ValidateGroupsFunc func(string, []string) ([]string, bool, error) + UserGroupsFunc func(string, []string, string) ([]string, error) + ValidateGroupsFunc func(string, []string, string) ([]string, bool, error) *ProviderData } @@ -62,13 +62,13 @@ func (tp *TestProvider) RefreshSession(s *sessions.SessionState, g []string) (bo } // UserGroups mocks the UserGroups function -func (tp *TestProvider) UserGroups(email string, groups []string) ([]string, error) { - return tp.UserGroupsFunc(email, groups) +func (tp *TestProvider) UserGroups(email string, groups []string, accessToken string) ([]string, error) { + return tp.UserGroupsFunc(email, groups, accessToken) } // ValidateGroup mocks the ValidateGroup function -func (tp *TestProvider) ValidateGroup(email string, groups []string) ([]string, bool, error) { - return tp.ValidateGroupsFunc(email, groups) +func (tp *TestProvider) ValidateGroup(email string, groups []string, accessToken string) ([]string, bool, error) { + return tp.ValidateGroupsFunc(email, groups, accessToken) } // GetSignOutURL mocks GetSignOutURL function