From 4b54433ec2c97bd14f50a9f6f3a18d8586af2133 Mon Sep 17 00:00:00 2001 From: "m.nabokikh" Date: Thu, 27 May 2021 17:11:12 +0400 Subject: [PATCH] Bump golag-ci lint version to 1.40.1 Signed-off-by: m.nabokikh --- .golangci.yml | 4 +--- Makefile | 7 +++++-- server/handlers.go | 10 +++++----- server/oauth2.go | 4 ++-- storage/ent/client/offlinesession.go | 4 ++-- storage/memory/memory.go | 3 +-- storage/storage.go | 2 +- 7 files changed, 17 insertions(+), 17 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index e182d624..7eca5c37 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -6,8 +6,6 @@ linters-settings: local-prefixes: github.com/dexidp/dex goimports: local-prefixes: github.com/dexidp/dex - golint: - min-confidence: 0 linters: @@ -24,7 +22,6 @@ linters: - gofmt - gofumpt - goimports - - golint - goprintffuncname - gosimple - govet @@ -33,6 +30,7 @@ linters: - nakedret - nolintlint - prealloc + - revive - rowserrcheck - sqlclosecheck - staticcheck diff --git a/Makefile b/Makefile index 0c22b256..81923af4 100644 --- a/Makefile +++ b/Makefile @@ -20,7 +20,7 @@ export GOBIN=$(PWD)/bin LD_FLAGS="-w -X main.version=$(VERSION)" # Dependency versions -GOLANGCI_VERSION = 1.32.2 +GOLANGCI_VERSION = 1.40.1 PROTOC_VERSION = 3.15.6 PROTOC_GEN_GO_VERSION = 1.26.0 @@ -86,10 +86,13 @@ bin/golangci-lint-${GOLANGCI_VERSION}: curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | BINARY=golangci-lint bash -s -- v${GOLANGCI_VERSION} @mv bin/golangci-lint $@ -.PHONY: lint +.PHONY: lint lint-fix lint: bin/golangci-lint ## Run linter bin/golangci-lint run +lint-fix: bin/golangci-lint ## Run linter and fix issues + bin/golangci-lint run --fix + .PHONY: fix fix: bin/golangci-lint ## Fix lint violations bin/golangci-lint run --fix diff --git a/server/handlers.go b/server/handlers.go index f39db575..e7facca6 100644 --- a/server/handlers.go +++ b/server/handlers.go @@ -24,8 +24,8 @@ import ( ) const ( - CodeChallengeMethodPlain = "plain" - CodeChallengeMethodS256 = "S256" + codeChallengeMethodPlain = "plain" + codeChallengeMethodS256 = "S256" ) func (s *Server) handlePublicKeys(w http.ResponseWriter, r *http.Request) { @@ -96,7 +96,7 @@ func (s *Server) discoveryHandler() (http.HandlerFunc, error) { Subjects: []string{"public"}, GrantTypes: []string{grantTypeAuthorizationCode, grantTypeRefreshToken, grantTypeDeviceCode}, IDTokenAlgs: []string{string(jose.RS256)}, - CodeChallengeAlgs: []string{CodeChallengeMethodS256, CodeChallengeMethodPlain}, + CodeChallengeAlgs: []string{codeChallengeMethodS256, codeChallengeMethodPlain}, Scopes: []string{"openid", "email", "groups", "profile", "offline_access"}, AuthMethods: []string{"client_secret_basic", "client_secret_post"}, Claims: []string{ @@ -724,9 +724,9 @@ func (s *Server) handleToken(w http.ResponseWriter, r *http.Request) { func (s *Server) calculateCodeChallenge(codeVerifier, codeChallengeMethod string) (string, error) { switch codeChallengeMethod { - case CodeChallengeMethodPlain: + case codeChallengeMethodPlain: return codeVerifier, nil - case CodeChallengeMethodS256: + case codeChallengeMethodS256: shaSum := sha256.Sum256([]byte(codeVerifier)) return base64.RawURLEncoding.EncodeToString(shaSum[:]), nil default: diff --git a/server/oauth2.go b/server/oauth2.go index 577fb944..00beb6ff 100644 --- a/server/oauth2.go +++ b/server/oauth2.go @@ -428,7 +428,7 @@ func (s *Server) parseAuthorizationRequest(r *http.Request) (*storage.AuthReques codeChallengeMethod := q.Get("code_challenge_method") if codeChallengeMethod == "" { - codeChallengeMethod = CodeChallengeMethodPlain + codeChallengeMethod = codeChallengeMethodPlain } client, err := s.storage.GetClient(clientID) @@ -470,7 +470,7 @@ func (s *Server) parseAuthorizationRequest(r *http.Request) (*storage.AuthReques return nil, newErr(errRequestNotSupported, "Server does not support request parameter.") } - if codeChallengeMethod != CodeChallengeMethodS256 && codeChallengeMethod != CodeChallengeMethodPlain { + if codeChallengeMethod != codeChallengeMethodS256 && codeChallengeMethod != codeChallengeMethodPlain { description := fmt.Sprintf("Unsupported PKCE challenge method (%q).", codeChallengeMethod) return nil, newErr(errInvalidRequest, description) } diff --git a/storage/ent/client/offlinesession.go b/storage/ent/client/offlinesession.go index cee415b6..161042ab 100644 --- a/storage/ent/client/offlinesession.go +++ b/storage/ent/client/offlinesession.go @@ -51,7 +51,7 @@ func (d *Database) DeleteOfflineSessions(userID, connID string) error { return nil } -// UpdatePassword changes an offline session by user id and connector id using an updater function. +// UpdateOfflineSessions changes an offline session by user id and connector id using an updater function. func (d *Database) UpdateOfflineSessions(userID string, connID string, updater func(s storage.OfflineSessions) (storage.OfflineSessions, error)) error { id := offlineSessionID(userID, connID, d.hasher) @@ -86,7 +86,7 @@ func (d *Database) UpdateOfflineSessions(userID string, connID string, updater f } if err = tx.Commit(); err != nil { - return rollback(tx, "update password commit: %w", err) + return rollback(tx, "update offline session commit: %w", err) } return nil diff --git a/storage/memory/memory.go b/storage/memory/memory.go index 82264205..a9406657 100644 --- a/storage/memory/memory.go +++ b/storage/memory/memory.go @@ -29,8 +29,7 @@ func New(logger log.Logger) storage.Storage { // Config is an implementation of a storage configuration. // // TODO(ericchiang): Actually define a storage config interface and have registration. -type Config struct { - // The in memory implementation has no config. +type Config struct { // The in memory implementation has no config. } // Open always returns a new in memory storage. diff --git a/storage/storage.go b/storage/storage.go index 855eb09f..cdd83ca6 100644 --- a/storage/storage.go +++ b/storage/storage.go @@ -177,7 +177,7 @@ type Claims struct { Groups []string } -// Data needed for PKCE (RFC 7636) +// PKCE is a container for the data needed to perform Proof Key for Code Exchange (RFC 7636) auth flow type PKCE struct { CodeChallenge string CodeChallengeMethod string