1
0
mirror of https://github.com/oauth2-proxy/oauth2-proxy.git synced 2025-06-15 00:15:00 +02:00

Updated linters

This commit is contained in:
kvanzuijlen
2023-10-24 16:31:32 +02:00
parent 8d03adfd04
commit e13a5048eb
9 changed files with 18 additions and 22 deletions

View File

@ -3,19 +3,15 @@ run:
linters: linters:
enable: enable:
- govet - govet
- golint
- ineffassign - ineffassign
- goconst - goconst
- deadcode
- gofmt - gofmt
- goimports - goimports
- gosec - gosec
- gosimple - gosimple
- staticcheck - staticcheck
- structcheck
- typecheck - typecheck
- unused - unused
- varcheck
- bodyclose - bodyclose
- dogsled - dogsled
- goprintffuncname - goprintffuncname
@ -25,6 +21,7 @@ linters:
- stylecheck - stylecheck
- unconvert - unconvert
- gocritic - gocritic
- revive
disable-all: true disable-all: true
issues: issues:
exclude-rules: exclude-rules:
@ -38,6 +35,6 @@ issues:
# If we have tests in shared test folders, these can be less strictly linted # If we have tests in shared test folders, these can be less strictly linted
- path: tests/.*_tests\.go - path: tests/.*_tests\.go
linters: linters:
- golint - revive
- bodyclose - bodyclose
- stylecheck - stylecheck

View File

@ -448,9 +448,8 @@ func (patTest *PassAccessTokenTest) getEndpointWithCookie(cookie string, endpoin
value = strings.TrimPrefix(field, keyPrefix) value = strings.TrimPrefix(field, keyPrefix)
if value != field { if value != field {
break break
} else {
value = ""
} }
value = ""
} }
if value == "" { if value == "" {
return 0, "" return 0, ""
@ -612,7 +611,7 @@ func (sipTest *SignInPageTest) GetEndpoint(endpoint string) (int, string) {
type AlwaysSuccessfulValidator struct { type AlwaysSuccessfulValidator struct {
} }
func (AlwaysSuccessfulValidator) Validate(user, password string) bool { func (AlwaysSuccessfulValidator) Validate(_, _ string) bool {
return true return true
} }

View File

@ -7,18 +7,18 @@ import (
type NoOpLock struct{} type NoOpLock struct{}
func (l *NoOpLock) Obtain(ctx context.Context, expiration time.Duration) error { func (l *NoOpLock) Obtain(_ context.Context, _ time.Duration) error {
return nil return nil
} }
func (l *NoOpLock) Peek(ctx context.Context) (bool, error) { func (l *NoOpLock) Peek(_ context.Context) (bool, error) {
return false, nil return false, nil
} }
func (l *NoOpLock) Refresh(ctx context.Context, expiration time.Duration) error { func (l *NoOpLock) Refresh(_ context.Context, _ time.Duration) error {
return nil return nil
} }
func (l *NoOpLock) Release(ctx context.Context) error { func (l *NoOpLock) Release(_ context.Context) error {
return nil return nil
} }

View File

@ -199,7 +199,7 @@ type testVerifier struct {
jwk jose.JSONWebKey jwk jose.JSONWebKey
} }
func (t *testVerifier) VerifySignature(ctx context.Context, jwt string) ([]byte, error) { func (t *testVerifier) VerifySignature(_ context.Context, jwt string) ([]byte, error) {
jws, err := jose.ParseSigned(jwt) jws, err := jose.ParseSigned(jwt)
if err != nil { if err != nil {
return nil, fmt.Errorf("oidc: malformed jwt: %v", err) return nil, fmt.Errorf("oidc: malformed jwt: %v", err)

View File

@ -12,19 +12,19 @@ type MockLock struct {
elapsed time.Duration elapsed time.Duration
} }
func (l *MockLock) Obtain(ctx context.Context, expiration time.Duration) error { func (l *MockLock) Obtain(_ context.Context, expiration time.Duration) error {
l.expiration = expiration l.expiration = expiration
return nil return nil
} }
func (l *MockLock) Peek(ctx context.Context) (bool, error) { func (l *MockLock) Peek(_ context.Context) (bool, error) {
if l.elapsed < l.expiration { if l.elapsed < l.expiration {
return true, nil return true, nil
} }
return false, nil return false, nil
} }
func (l *MockLock) Refresh(ctx context.Context, expiration time.Duration) error { func (l *MockLock) Refresh(_ context.Context, expiration time.Duration) error {
if l.expiration <= l.elapsed { if l.expiration <= l.elapsed {
return sessions.ErrNotLocked return sessions.ErrNotLocked
} }
@ -33,7 +33,7 @@ func (l *MockLock) Refresh(ctx context.Context, expiration time.Duration) error
return nil return nil
} }
func (l *MockLock) Release(ctx context.Context) error { func (l *MockLock) Release(_ context.Context) error {
if l.expiration <= l.elapsed { if l.expiration <= l.elapsed {
return sessions.ErrNotLocked return sessions.ErrNotLocked
} }

View File

@ -38,7 +38,7 @@ func validateHeader(header options.Header, names map[string]struct{}) []string {
return msgs return msgs
} }
func validateHeaderValue(name string, value options.HeaderValue) []string { func validateHeaderValue(_ string, value options.HeaderValue) []string {
switch { switch {
case value.SecretSource != nil && value.ClaimSource == nil: case value.SecretSource != nil && value.ClaimSource == nil:
return []string{validateSecretSource(*value.SecretSource)} return []string{validateSecretSource(*value.SecretSource)}

View File

@ -93,7 +93,7 @@ func (p *ADFSProvider) RefreshSession(ctx context.Context, s *sessions.SessionSt
return refreshed, err return refreshed, err
} }
func (p *ADFSProvider) fallbackUPN(ctx context.Context, s *sessions.SessionState) error { func (p *ADFSProvider) fallbackUPN(_ context.Context, s *sessions.SessionState) error {
claims, err := p.getClaimExtractor(s.IDToken, s.AccessToken) claims, err := p.getClaimExtractor(s.IDToken, s.AccessToken)
if err != nil { if err != nil {
return fmt.Errorf("could not extract claims: %v", err) return fmt.Errorf("could not extract claims: %v", err)

View File

@ -26,13 +26,13 @@ type ValidateSessionTestProvider struct {
var _ Provider = (*ValidateSessionTestProvider)(nil) var _ Provider = (*ValidateSessionTestProvider)(nil)
func (tp *ValidateSessionTestProvider) GetEmailAddress(ctx context.Context, s *sessions.SessionState) (string, error) { func (tp *ValidateSessionTestProvider) GetEmailAddress(_ context.Context, _ *sessions.SessionState) (string, error) {
return "", errors.New("not implemented") return "", errors.New("not implemented")
} }
// Note that we're testing the internal validateToken() used to implement // Note that we're testing the internal validateToken() used to implement
// several Provider's ValidateSession() implementations // several Provider's ValidateSession() implementations
func (tp *ValidateSessionTestProvider) ValidateSession(ctx context.Context, s *sessions.SessionState) bool { func (tp *ValidateSessionTestProvider) ValidateSession(_ context.Context, _ *sessions.SessionState) bool {
return false return false
} }

View File

@ -93,7 +93,7 @@ func (p *OIDCProvider) Redeem(ctx context.Context, redirectURL, code, codeVerifi
// EnrichSession is called after Redeem to allow providers to enrich session fields // EnrichSession is called after Redeem to allow providers to enrich session fields
// such as User, Email, Groups with provider specific API calls. // such as User, Email, Groups with provider specific API calls.
func (p *OIDCProvider) EnrichSession(ctx context.Context, s *sessions.SessionState) error { func (p *OIDCProvider) EnrichSession(_ context.Context, s *sessions.SessionState) error {
// If a mandatory email wasn't set, error at this point. // If a mandatory email wasn't set, error at this point.
if s.Email == "" { if s.Email == "" {
return errors.New("neither the id_token nor the profileURL set an email") return errors.New("neither the id_token nor the profileURL set an email")