diff options
author | 6543 <6543@obermui.de> | 2022-01-20 18:46:10 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-20 18:46:10 +0100 |
commit | 54e9ee37a7a301dbe74d46fd3c87712e6120e9bf (patch) | |
tree | 1be12fb072625c1b896b9d72f7912b018aad502b /services/auth | |
parent | 1d98d205f5825f40110e6628b61a97c91ac7f72d (diff) | |
download | gitea-54e9ee37a7a301dbe74d46fd3c87712e6120e9bf.tar.gz gitea-54e9ee37a7a301dbe74d46fd3c87712e6120e9bf.zip |
format with gofumpt (#18184)
* gofumpt -w -l .
* gofumpt -w -l -extra .
* Add linter
* manual fix
* change make fmt
Diffstat (limited to 'services/auth')
-rw-r--r-- | services/auth/auth.go | 6 | ||||
-rw-r--r-- | services/auth/auth_test.go | 1 | ||||
-rw-r--r-- | services/auth/basic.go | 3 | ||||
-rw-r--r-- | services/auth/oauth2.go | 3 | ||||
-rw-r--r-- | services/auth/reverseproxy.go | 3 | ||||
-rw-r--r-- | services/auth/session.go | 3 | ||||
-rw-r--r-- | services/auth/source/ldap/source_sync.go | 1 | ||||
-rw-r--r-- | services/auth/source/oauth2/jwtsigningkey.go | 2 | ||||
-rw-r--r-- | services/auth/source/oauth2/providers.go | 6 | ||||
-rw-r--r-- | services/auth/source/oauth2/providers_openid.go | 3 | ||||
-rw-r--r-- | services/auth/source/oauth2/providers_simple.go | 1 | ||||
-rw-r--r-- | services/auth/source/oauth2/source_callout.go | 2 | ||||
-rw-r--r-- | services/auth/source/smtp/auth.go | 6 |
13 files changed, 15 insertions, 25 deletions
diff --git a/services/auth/auth.go b/services/auth/auth.go index 3eb7f027d2..bdff777f50 100644 --- a/services/auth/auth.go +++ b/services/auth/auth.go @@ -95,8 +95,10 @@ func isAttachmentDownload(req *http.Request) bool { return strings.HasPrefix(req.URL.Path, "/attachments/") && req.Method == "GET" } -var gitRawReleasePathRe = regexp.MustCompile(`^/[a-zA-Z0-9_.-]+/[a-zA-Z0-9_.-]+/(?:(?:git-(?:(?:upload)|(?:receive))-pack$)|(?:info/refs$)|(?:HEAD$)|(?:objects/)|(?:raw/)|(?:releases/download/))`) -var lfsPathRe = regexp.MustCompile(`^/[a-zA-Z0-9_.-]+/[a-zA-Z0-9_.-]+/info/lfs/`) +var ( + gitRawReleasePathRe = regexp.MustCompile(`^/[a-zA-Z0-9_.-]+/[a-zA-Z0-9_.-]+/(?:(?:git-(?:(?:upload)|(?:receive))-pack$)|(?:info/refs$)|(?:HEAD$)|(?:objects/)|(?:raw/)|(?:releases/download/))`) + lfsPathRe = regexp.MustCompile(`^/[a-zA-Z0-9_.-]+/[a-zA-Z0-9_.-]+/info/lfs/`) +) func isGitRawReleaseOrLFSPath(req *http.Request) bool { if gitRawReleasePathRe.MatchString(req.URL.Path) { diff --git a/services/auth/auth_test.go b/services/auth/auth_test.go index b0d23bb4e9..8a9dee6cef 100644 --- a/services/auth/auth_test.go +++ b/services/auth/auth_test.go @@ -13,7 +13,6 @@ import ( ) func Test_isGitRawOrLFSPath(t *testing.T) { - tests := []struct { path string diff --git a/services/auth/basic.go b/services/auth/basic.go index e2448eeca0..d8667c65d5 100644 --- a/services/auth/basic.go +++ b/services/auth/basic.go @@ -30,8 +30,7 @@ const BasicMethodName = "basic" // Basic implements the Auth interface and authenticates requests (API requests // only) by looking for Basic authentication data or "x-oauth-basic" token in the "Authorization" // header. -type Basic struct { -} +type Basic struct{} // Name represents the name of auth method func (b *Basic) Name() string { diff --git a/services/auth/oauth2.go b/services/auth/oauth2.go index fae981d800..fcff5313e3 100644 --- a/services/auth/oauth2.go +++ b/services/auth/oauth2.go @@ -53,8 +53,7 @@ func CheckOAuthAccessToken(accessToken string) int64 { // OAuth2 implements the Auth interface and authenticates requests // (API requests only) by looking for an OAuth token in query parameters or the // "Authorization" header. -type OAuth2 struct { -} +type OAuth2 struct{} // Name represents the name of auth method func (o *OAuth2) Name() string { diff --git a/services/auth/reverseproxy.go b/services/auth/reverseproxy.go index 3e44d8b863..1b151f6504 100644 --- a/services/auth/reverseproxy.go +++ b/services/auth/reverseproxy.go @@ -32,8 +32,7 @@ const ReverseProxyMethodName = "reverse_proxy" // On successful authentication the proxy is expected to populate the username in the // "setting.ReverseProxyAuthUser" header. Optionally it can also populate the email of the // user in the "setting.ReverseProxyAuthEmail" header. -type ReverseProxy struct { -} +type ReverseProxy struct{} // getUserName extracts the username from the "setting.ReverseProxyAuthUser" header func (r *ReverseProxy) getUserName(req *http.Request) string { diff --git a/services/auth/session.go b/services/auth/session.go index 256598d100..6a23a17665 100644 --- a/services/auth/session.go +++ b/services/auth/session.go @@ -19,8 +19,7 @@ var ( // Session checks if there is a user uid stored in the session and returns the user // object for that uid. -type Session struct { -} +type Session struct{} // Name represents the name of auth method func (s *Session) Name() string { diff --git a/services/auth/source/ldap/source_sync.go b/services/auth/source/ldap/source_sync.go index 78aa90aaa5..398d9ef798 100644 --- a/services/auth/source/ldap/source_sync.go +++ b/services/auth/source/ldap/source_sync.go @@ -164,7 +164,6 @@ func (source *Source) Sync(ctx context.Context, updateExisting bool) error { if err == nil && len(source.AttributeAvatar) > 0 { _ = user_service.UploadAvatar(usr, su.Avatar) } - } } } diff --git a/services/auth/source/oauth2/jwtsigningkey.go b/services/auth/source/oauth2/jwtsigningkey.go index 187c6999e0..24f2c41119 100644 --- a/services/auth/source/oauth2/jwtsigningkey.go +++ b/services/auth/source/oauth2/jwtsigningkey.go @@ -410,7 +410,7 @@ func loadOrCreateAsymmetricKey() (interface{}, error) { return err } - f, err := os.OpenFile(keyPath, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0600) + f, err := os.OpenFile(keyPath, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0o600) if err != nil { return err } diff --git a/services/auth/source/oauth2/providers.go b/services/auth/source/oauth2/providers.go index 065c6884e0..45851c8799 100644 --- a/services/auth/source/oauth2/providers.go +++ b/services/auth/source/oauth2/providers.go @@ -139,10 +139,8 @@ func ClearProviders() { goth.ClearProviders() } -var ( - // ErrAuthSourceNotActived login source is not actived error - ErrAuthSourceNotActived = errors.New("auth source is not actived") -) +// ErrAuthSourceNotActived login source is not actived error +var ErrAuthSourceNotActived = errors.New("auth source is not actived") // used to create different types of goth providers func createProvider(providerName string, source *Source) (goth.Provider, error) { diff --git a/services/auth/source/oauth2/providers_openid.go b/services/auth/source/oauth2/providers_openid.go index 838311b4a1..80ee56d4a4 100644 --- a/services/auth/source/oauth2/providers_openid.go +++ b/services/auth/source/oauth2/providers_openid.go @@ -13,8 +13,7 @@ import ( ) // OpenIDProvider is a GothProvider for OpenID -type OpenIDProvider struct { -} +type OpenIDProvider struct{} // Name provides the technical name for this provider func (o *OpenIDProvider) Name() string { diff --git a/services/auth/source/oauth2/providers_simple.go b/services/auth/source/oauth2/providers_simple.go index a4d61eb2f3..0f118b596d 100644 --- a/services/auth/source/oauth2/providers_simple.go +++ b/services/auth/source/oauth2/providers_simple.go @@ -107,5 +107,4 @@ func init() { return microsoftonline.New(clientID, secret, callbackURL, scopes...) }, )) - } diff --git a/services/auth/source/oauth2/source_callout.go b/services/auth/source/oauth2/source_callout.go index 8596dd187d..7447e5d453 100644 --- a/services/auth/source/oauth2/source_callout.go +++ b/services/auth/source/oauth2/source_callout.go @@ -18,7 +18,7 @@ func (source *Source) Callout(request *http.Request, response http.ResponseWrite // don't use the default gothic begin handler to prevent issues when some error occurs // normally the gothic library will write some custom stuff to the response instead of our own nice error page - //gothic.BeginAuthHandler(response, request) + // gothic.BeginAuthHandler(response, request) gothRWMutex.RLock() defer gothRWMutex.RUnlock() diff --git a/services/auth/source/smtp/auth.go b/services/auth/source/smtp/auth.go index c5bd09b0a7..8d0cbb11cd 100644 --- a/services/auth/source/smtp/auth.go +++ b/services/auth/source/smtp/auth.go @@ -51,10 +51,8 @@ const ( // Authenticators contains available SMTP authentication type names. var Authenticators = []string{PlainAuthentication, LoginAuthentication, CRAMMD5Authentication} -var ( - // ErrUnsupportedLoginType login source is unknown error - ErrUnsupportedLoginType = errors.New("Login source is unknown") -) +// ErrUnsupportedLoginType login source is unknown error +var ErrUnsupportedLoginType = errors.New("Login source is unknown") // Authenticate performs an SMTP authentication. func Authenticate(a smtp.Auth, source *Source) error { |