git.iko.soy/typeable/oauth2-proxy
on master help sign in
Updated linters
commite13a5048eb41c118adbb1c8e8342a61c9e5d6b98 authorkvanzuijlen <8818390+kvanzuijlen@users.noreply.github.com> dateTue 24 Oct 2023, 16:31 (3 years ago) parent8d03adf
9 files changed+18−22
.golangci.yml+2−5 oauthproxy_test.go+2−3 pkg/apis/sessions/lock.go+4−4 pkg/providers/oidc/verifier_test.go+1−1 pkg/sessions/tests/mock_lock.go+4−4 pkg/validation/header.go+1−1 providers/adfs.go+1−1 providers/internal_util_test.go+2−2 providers/oidc.go+1−1
.golangci.yml+2−5
@@ -3,19 +3,15 @@ run:
33linters:
44 enable:
55 - govet
6− - golint
76 - ineffassign
87 - goconst
9− - deadcode
108 - gofmt
119 - goimports
1210 - gosec
1311 - gosimple
1412 - staticcheck
15− - structcheck
1613 - typecheck
1714 - unused
18− - varcheck
1915 - bodyclose
2016 - dogsled
2117 - goprintffuncname
@@ -25,6 +21,7 @@ linters:
2521 - stylecheck
2622 - unconvert
2723 - gocritic
24+ - revive
2825 disable-all: true
2926issues:
3027 exclude-rules:
@@ -38,6 +35,6 @@ issues:
3835 # If we have tests in shared test folders, these can be less strictly linted
3936 - path: tests/.*_tests\.go
4037 linters:
41− - golint
38+ - revive
4239 - bodyclose
4340 - stylecheck
oauthproxy_test.go+2−3
@@ -448,9 +448,8 @@ func (patTest *PassAccessTokenTest) getEndpointWithCookie(cookie string, endpoin
448448 value = strings.TrimPrefix(field, keyPrefix)
449449 if value != field {
450450 break
451− } else {
452− value = ""
453451 }
452+ value = ""
454453 }
455454 if value == "" {
456455 return 0, ""
@@ -612,7 +611,7 @@ func (sipTest *SignInPageTest) GetEndpoint(endpoint string) (int, string) {
612611type AlwaysSuccessfulValidator struct {
613612}
614613
615−func (AlwaysSuccessfulValidator) Validate(user, password string) bool {
614+func (AlwaysSuccessfulValidator) Validate(_, _ string) bool {
616615 return true
617616}
618617
pkg/apis/sessions/lock.go+4−4
@@ -7,18 +7,18 @@ import (
77
88type NoOpLock struct{}
99
10−func (l *NoOpLock) Obtain(ctx context.Context, expiration time.Duration) error {
10+func (l *NoOpLock) Obtain(_ context.Context, _ time.Duration) error {
1111 return nil
1212}
1313
14−func (l *NoOpLock) Peek(ctx context.Context) (bool, error) {
14+func (l *NoOpLock) Peek(_ context.Context) (bool, error) {
1515 return false, nil
1616}
1717
18−func (l *NoOpLock) Refresh(ctx context.Context, expiration time.Duration) error {
18+func (l *NoOpLock) Refresh(_ context.Context, _ time.Duration) error {
1919 return nil
2020}
2121
22−func (l *NoOpLock) Release(ctx context.Context) error {
22+func (l *NoOpLock) Release(_ context.Context) error {
2323 return nil
2424}
pkg/providers/oidc/verifier_test.go+1−1
@@ -199,7 +199,7 @@ type testVerifier struct {
199199 jwk jose.JSONWebKey
200200}
201201
202−func (t *testVerifier) VerifySignature(ctx context.Context, jwt string) ([]byte, error) {
202+func (t *testVerifier) VerifySignature(_ context.Context, jwt string) ([]byte, error) {
203203 jws, err := jose.ParseSigned(jwt)
204204 if err != nil {
205205 return nil, fmt.Errorf("oidc: malformed jwt: %v", err)
pkg/sessions/tests/mock_lock.go+4−4
@@ -12,19 +12,19 @@ type MockLock struct {
1212 elapsed time.Duration
1313}
1414
15−func (l *MockLock) Obtain(ctx context.Context, expiration time.Duration) error {
15+func (l *MockLock) Obtain(_ context.Context, expiration time.Duration) error {
1616 l.expiration = expiration
1717 return nil
1818}
1919
20−func (l *MockLock) Peek(ctx context.Context) (bool, error) {
20+func (l *MockLock) Peek(_ context.Context) (bool, error) {
2121 if l.elapsed < l.expiration {
2222 return true, nil
2323 }
2424 return false, nil
2525}
2626
27−func (l *MockLock) Refresh(ctx context.Context, expiration time.Duration) error {
27+func (l *MockLock) Refresh(_ context.Context, expiration time.Duration) error {
2828 if l.expiration <= l.elapsed {
2929 return sessions.ErrNotLocked
3030 }
@@ -33,7 +33,7 @@ func (l *MockLock) Refresh(ctx context.Context, expiration time.Duration) error
3333 return nil
3434}
3535
36−func (l *MockLock) Release(ctx context.Context) error {
36+func (l *MockLock) Release(_ context.Context) error {
3737 if l.expiration <= l.elapsed {
3838 return sessions.ErrNotLocked
3939 }
pkg/validation/header.go+1−1
@@ -38,7 +38,7 @@ func validateHeader(header options.Header, names map[string]struct{}) []string {
3838 return msgs
3939}
4040
41−func validateHeaderValue(name string, value options.HeaderValue) []string {
41+func validateHeaderValue(_ string, value options.HeaderValue) []string {
4242 switch {
4343 case value.SecretSource != nil && value.ClaimSource == nil:
4444 return []string{validateSecretSource(*value.SecretSource)}
providers/adfs.go+1−1
@@ -93,7 +93,7 @@ func (p *ADFSProvider) RefreshSession(ctx context.Context, s *sessions.SessionSt
9393 return refreshed, err
9494}
9595
96−func (p *ADFSProvider) fallbackUPN(ctx context.Context, s *sessions.SessionState) error {
96+func (p *ADFSProvider) fallbackUPN(_ context.Context, s *sessions.SessionState) error {
9797 claims, err := p.getClaimExtractor(s.IDToken, s.AccessToken)
9898 if err != nil {
9999 return fmt.Errorf("could not extract claims: %v", err)
providers/internal_util_test.go+2−2
@@ -26,13 +26,13 @@ type ValidateSessionTestProvider struct {
2626
2727var _ Provider = (*ValidateSessionTestProvider)(nil)
2828
29−func (tp *ValidateSessionTestProvider) GetEmailAddress(ctx context.Context, s *sessions.SessionState) (string, error) {
29+func (tp *ValidateSessionTestProvider) GetEmailAddress(_ context.Context, _ *sessions.SessionState) (string, error) {
3030 return "", errors.New("not implemented")
3131}
3232
3333// Note that we're testing the internal validateToken() used to implement
3434// several Provider's ValidateSession() implementations
35−func (tp *ValidateSessionTestProvider) ValidateSession(ctx context.Context, s *sessions.SessionState) bool {
35+func (tp *ValidateSessionTestProvider) ValidateSession(_ context.Context, _ *sessions.SessionState) bool {
3636 return false
3737}
3838
providers/oidc.go+1−1
@@ -93,7 +93,7 @@ func (p *OIDCProvider) Redeem(ctx context.Context, redirectURL, code, codeVerifi
9393
9494// EnrichSession is called after Redeem to allow providers to enrich session fields
9595// such as User, Email, Groups with provider specific API calls.
96−func (p *OIDCProvider) EnrichSession(ctx context.Context, s *sessions.SessionState) error {
96+func (p *OIDCProvider) EnrichSession(_ context.Context, s *sessions.SessionState) error {
9797 // If a mandatory email wasn't set, error at this point.
9898 if s.Email == "" {
9999 return errors.New("neither the id_token nor the profileURL set an email")