Skip to content

Commit a79e7f2

Browse files
committed
Fix lint for windows
1 parent ef4c900 commit a79e7f2

File tree

3 files changed

+19
-12
lines changed

3 files changed

+19
-12
lines changed

services/auth/auth.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ func Init() {
5555
if setting.Service.EnableReverseProxyAuth {
5656
Register(&ReverseProxy{})
5757
}
58+
specialInit()
5859
for _, method := range Methods() {
5960
err := method.Init()
6061
if err != nil {

services/auth/placeholder.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// Copyright 2021 The Gitea Authors. All rights reserved.
2+
// Use of this source code is governed by a MIT-style
3+
// license that can be found in the LICENSE file.
4+
5+
// +build !windows
6+
7+
package auth
8+
9+
func specialInit() {}

services/auth/sspi_windows.go

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ var (
3232
sspiAuth *websspi.Authenticator
3333

3434
// Ensure the struct implements the interface.
35-
_ Auth = &SSPI{}
35+
_ SingleSignOn = &SSPI{}
3636
)
3737

38-
// SSPI implements the Auth interface and authenticates requests
38+
// SSPI implements the SingleSignOn interface and authenticates requests
3939
// via the built-in SSPI module in Windows for SPNEGO authentication.
4040
// On successful authentication returns a valid user object.
4141
// Returns nil if authentication fails.
@@ -72,16 +72,11 @@ func (s *SSPI) Free() error {
7272
return sspiAuth.Free()
7373
}
7474

75-
// IsEnabled checks if there is an active SSPI authentication source
76-
func (s *SSPI) IsEnabled() bool {
77-
return models.IsSSPIEnabled()
78-
}
79-
80-
// VerifyAuthData uses SSPI (Windows implementation of SPNEGO) to authenticate the request.
75+
// Verify uses SSPI (Windows implementation of SPNEGO) to authenticate the request.
8176
// If authentication is successful, returs the corresponding user object.
8277
// If negotiation should continue or authentication fails, immediately returns a 401 HTTP
8378
// response code, as required by the SPNEGO protocol.
84-
func (s *SSPI) VerifyAuthData(req *http.Request, w http.ResponseWriter, store DataStore, sess SessionStore) *models.User {
79+
func (s *SSPI) Verify(req *http.Request, w http.ResponseWriter, store DataStore, sess SessionStore) *models.User {
8580
if !s.shouldAuthenticate(req) {
8681
return nil
8782
}
@@ -240,10 +235,12 @@ func sanitizeUsername(username string, cfg *models.SSPIConfig) string {
240235
return username
241236
}
242237

243-
// init registers the SSPI auth method as the last method in the list.
238+
// specialInit registers the SSPI auth method as the last method in the list.
244239
// The SSPI plugin is expected to be executed last, as it returns 401 status code if negotiation
245240
// fails (or if negotiation should continue), which would prevent other authentication methods
246241
// to execute at all.
247-
func init() {
248-
Register(&SSPI{})
242+
func specialInit() {
243+
if models.IsSSPIEnabled() {
244+
Register(&SSPI{})
245+
}
249246
}

0 commit comments

Comments
 (0)