git.iko.soy/typeable/oauth2-proxy
on master help sign in
Cleanup method name refactors missed in comments
commit26ed080bed999009f61d67b99612e78fc2e660a4 authorNick Meves <nick.meves@greenhouse.io> dateSun 29 Nov 2020, 14:12 (6 years ago) parentf6ae15e
9 files changed+33−32
CHANGELOG.md+1 providers/azure.go+2−2 providers/digitalocean.go+1−1 providers/github.go+2−2 providers/gitlab.go+1−1 providers/google.go+2−2 providers/internal_util_test.go+20−20 providers/provider_default.go+3−3 providers/providers.go+1−1
CHANGELOG.md+1
@@ -43,6 +43,7 @@
4343
4444## Changes since v6.1.1
4545
46+- [#938](https://github.com/oauth2-proxy/oauth2-proxy/pull/938) Cleanup missed provider renaming refactor methods (@NickMeves)
4647- [#925](https://github.com/oauth2-proxy/oauth2-proxy/pull/925) Fix basic auth legacy header conversion (@JoelSpeed)
4748- [#916](https://github.com/oauth2-proxy/oauth2-proxy/pull/916) Add AlphaOptions struct to prepare for alpha config loading (@JoelSpeed)
4849- [#923](https://github.com/oauth2-proxy/oauth2-proxy/pull/923) Support TLS 1.3 (@aajisaka)
providers/azure.go+2−2
@@ -279,7 +279,7 @@ func (p *AzureProvider) GetLoginURL(redirectURI, state string) string {
279279 return a.String()
280280}
281281
282−// ValidateSessionState validates the AccessToken
283−func (p *AzureProvider) ValidateSessionState(ctx context.Context, s *sessions.SessionState) bool {
282+// ValidateSession validates the AccessToken
283+func (p *AzureProvider) ValidateSession(ctx context.Context, s *sessions.SessionState) bool {
284284 return validateToken(ctx, p, s.AccessToken, makeAzureHeader(s.AccessToken))
285285}
providers/digitalocean.go+1−1
@@ -82,7 +82,7 @@ func (p *DigitalOceanProvider) GetEmailAddress(ctx context.Context, s *sessions.
8282 return email, nil
8383}
8484
85−// ValidateSessionState validates the AccessToken
85+// ValidateSession validates the AccessToken
8686func (p *DigitalOceanProvider) ValidateSession(ctx context.Context, s *sessions.SessionState) bool {
8787 return validateToken(ctx, p, s.AccessToken, makeOIDCHeader(s.AccessToken))
8888}
providers/github.go+2−2
@@ -102,7 +102,7 @@ func (p *GitHubProvider) SetUsers(users []string) {
102102 p.Users = users
103103}
104104
105−// EnrichSessionState updates the User & Email after the initial Redeem
105+// EnrichSession updates the User & Email after the initial Redeem
106106func (p *GitHubProvider) EnrichSession(ctx context.Context, s *sessions.SessionState) error {
107107 err := p.getEmail(ctx, s)
108108 if err != nil {
@@ -111,7 +111,7 @@ func (p *GitHubProvider) EnrichSession(ctx context.Context, s *sessions.SessionS
111111 return p.getUser(ctx, s)
112112}
113113
114−// ValidateSessionState validates the AccessToken
114+// ValidateSession validates the AccessToken
115115func (p *GitHubProvider) ValidateSession(ctx context.Context, s *sessions.SessionState) bool {
116116 return validateToken(ctx, p, s.AccessToken, makeGitHubHeader(s.AccessToken))
117117}
providers/gitlab.go+1−1
@@ -187,7 +187,7 @@ func (p *GitLabProvider) createSessionState(ctx context.Context, token *oauth2.T
187187 }, nil
188188}
189189
190−// ValidateSessionState checks that the session's IDToken is still valid
190+// ValidateSession checks that the session's IDToken is still valid
191191func (p *GitLabProvider) ValidateSession(ctx context.Context, s *sessions.SessionState) bool {
192192 _, err := p.Verifier.Verify(ctx, s.IDToken)
193193 return err == nil
providers/google.go+2−2
@@ -177,10 +177,10 @@ func (p *GoogleProvider) Redeem(ctx context.Context, redirectURL, code string) (
177177 }, nil
178178}
179179
180−// EnrichSessionState checks the listed Google Groups configured and adds any
180+// EnrichSession checks the listed Google Groups configured and adds any
181181// that the user is a member of to session.Groups.
182182func (p *GoogleProvider) EnrichSession(ctx context.Context, s *sessions.SessionState) error {
183− // TODO (@NickMeves) - Move to pure EnrichSessionState logic and stop
183+ // TODO (@NickMeves) - Move to pure EnrichSession logic and stop
184184 // reusing legacy `groupValidator`.
185185 //
186186 // This is called here to get the validator to do the `session.Groups`
providers/internal_util_test.go+20−20
@@ -20,30 +20,30 @@ func updateURL(url *url.URL, hostname string) {
2020 url.Host = hostname
2121}
2222
23−type ValidateSessionStateTestProvider struct {
23+type ValidateSessionTestProvider struct {
2424 *ProviderData
2525}
2626
27−var _ Provider = (*ValidateSessionStateTestProvider)(nil)
27+var _ Provider = (*ValidateSessionTestProvider)(nil)
2828
29−func (tp *ValidateSessionStateTestProvider) GetEmailAddress(ctx context.Context, s *sessions.SessionState) (string, error) {
29+func (tp *ValidateSessionTestProvider) GetEmailAddress(ctx context.Context, s *sessions.SessionState) (string, error) {
3030 return "", errors.New("not implemented")
3131}
3232
3333// Note that we're testing the internal validateToken() used to implement
34−// several Provider's ValidateSessionState() implementations
35−func (tp *ValidateSessionStateTestProvider) ValidateSession(ctx context.Context, s *sessions.SessionState) bool {
34+// several Provider's ValidateSession() implementations
35+func (tp *ValidateSessionTestProvider) ValidateSession(ctx context.Context, s *sessions.SessionState) bool {
3636 return false
3737}
3838
3939type ValidateSessionStateTest struct {
4040 backend *httptest.Server
4141 responseCode int
42− provider *ValidateSessionStateTestProvider
42+ provider *ValidateSessionTestProvider
4343 header http.Header
4444}
4545
46−func NewValidateSessionStateTest() *ValidateSessionStateTest {
46+func NewValidateSessionTest() *ValidateSessionStateTest {
4747 var vtTest ValidateSessionStateTest
4848
4949 vtTest.backend = httptest.NewServer(
@@ -73,7 +73,7 @@ func NewValidateSessionStateTest() *ValidateSessionStateTest {
7373
7474 }))
7575 backendURL, _ := url.Parse(vtTest.backend.URL)
76− vtTest.provider = &ValidateSessionStateTestProvider{
76+ vtTest.provider = &ValidateSessionTestProvider{
7777 ProviderData: &ProviderData{
7878 ValidateURL: &url.URL{
7979 Scheme: "http",
@@ -90,14 +90,14 @@ func (vtTest *ValidateSessionStateTest) Close() {
9090 vtTest.backend.Close()
9191}
9292
93−func TestValidateSessionStateValidToken(t *testing.T) {
94− vtTest := NewValidateSessionStateTest()
93+func TestValidateSessionValidToken(t *testing.T) {
94+ vtTest := NewValidateSessionTest()
9595 defer vtTest.Close()
9696 assert.Equal(t, true, validateToken(context.Background(), vtTest.provider, "foobar", nil))
9797}
9898
99−func TestValidateSessionStateValidTokenWithHeaders(t *testing.T) {
100− vtTest := NewValidateSessionStateTest()
99+func TestValidateSessionValidTokenWithHeaders(t *testing.T) {
100+ vtTest := NewValidateSessionTest()
101101 defer vtTest.Close()
102102 vtTest.header = make(http.Header)
103103 vtTest.header.Set("Authorization", "Bearer foobar")
@@ -105,28 +105,28 @@ func TestValidateSessionStateValidTokenWithHeaders(t *testing.T) {
105105 validateToken(context.Background(), vtTest.provider, "foobar", vtTest.header))
106106}
107107
108−func TestValidateSessionStateEmptyToken(t *testing.T) {
109− vtTest := NewValidateSessionStateTest()
108+func TestValidateSessionEmptyToken(t *testing.T) {
109+ vtTest := NewValidateSessionTest()
110110 defer vtTest.Close()
111111 assert.Equal(t, false, validateToken(context.Background(), vtTest.provider, "", nil))
112112}
113113
114−func TestValidateSessionStateEmptyValidateURL(t *testing.T) {
115− vtTest := NewValidateSessionStateTest()
114+func TestValidateSessionEmptyValidateURL(t *testing.T) {
115+ vtTest := NewValidateSessionTest()
116116 defer vtTest.Close()
117117 vtTest.provider.Data().ValidateURL = nil
118118 assert.Equal(t, false, validateToken(context.Background(), vtTest.provider, "foobar", nil))
119119}
120120
121−func TestValidateSessionStateRequestNetworkFailure(t *testing.T) {
122− vtTest := NewValidateSessionStateTest()
121+func TestValidateSessionRequestNetworkFailure(t *testing.T) {
122+ vtTest := NewValidateSessionTest()
123123 // Close immediately to simulate a network failure
124124 vtTest.Close()
125125 assert.Equal(t, false, validateToken(context.Background(), vtTest.provider, "foobar", nil))
126126}
127127
128−func TestValidateSessionStateExpiredToken(t *testing.T) {
129− vtTest := NewValidateSessionStateTest()
128+func TestValidateSessionExpiredToken(t *testing.T) {
129+ vtTest := NewValidateSessionTest()
130130 defer vtTest.Close()
131131 vtTest.responseCode = 401
132132 assert.Equal(t, false, validateToken(context.Background(), vtTest.provider, "foobar", nil))
providers/provider_default.go+3−3
@@ -86,12 +86,12 @@ func (p *ProviderData) GetLoginURL(redirectURI, state string) string {
8686}
8787
8888// GetEmailAddress returns the Account email address
89−// DEPRECATED: Migrate to EnrichSessionState
89+// DEPRECATED: Migrate to EnrichSession
9090func (p *ProviderData) GetEmailAddress(_ context.Context, _ *sessions.SessionState) (string, error) {
9191 return "", ErrNotImplemented
9292}
9393
94−// EnrichSessionState is called after Redeem to allow providers to enrich session fields
94+// EnrichSession is called after Redeem to allow providers to enrich session fields
9595// such as User, Email, Groups with provider specific API calls.
9696func (p *ProviderData) EnrichSession(_ context.Context, _ *sessions.SessionState) error {
9797 return nil
@@ -113,7 +113,7 @@ func (p *ProviderData) Authorize(_ context.Context, s *sessions.SessionState) (b
113113 return false, nil
114114}
115115
116−// ValidateSessionState validates the AccessToken
116+// ValidateSession validates the AccessToken
117117func (p *ProviderData) ValidateSession(ctx context.Context, s *sessions.SessionState) bool {
118118 return validateToken(ctx, p, s.AccessToken, nil)
119119}
providers/providers.go+1−1
@@ -9,7 +9,7 @@ import (
99// Provider represents an upstream identity provider implementation
1010type Provider interface {
1111 Data() *ProviderData
12− // DEPRECATED: Migrate to EnrichSessionState
12+ // DEPRECATED: Migrate to EnrichSession
1313 GetEmailAddress(ctx context.Context, s *sessions.SessionState) (string, error)
1414 Redeem(ctx context.Context, redirectURI, code string) (*sessions.SessionState, error)
1515 EnrichSession(ctx context.Context, s *sessions.SessionState) error