diff options
Diffstat (limited to 'modules/auth/sso/sspi_windows.go')
-rw-r--r-- | modules/auth/sso/sspi_windows.go | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/modules/auth/sso/sspi_windows.go b/modules/auth/sso/sspi_windows.go index 62013737ca..5850dcf6e2 100644 --- a/modules/auth/sso/sspi_windows.go +++ b/modules/auth/sso/sspi_windows.go @@ -6,6 +6,7 @@ package sso import ( "errors" + "net/http" "reflect" "strings" @@ -64,7 +65,7 @@ func (s *SSPI) IsEnabled() bool { // If authentication is successful, returs the corresponding user object. // If negotiation should continue or authentication fails, immediately returns a 401 HTTP // response code, as required by the SPNEGO protocol. -func (s *SSPI) VerifyAuthData(ctx *macaron.Context, sess session.Store) *models.User { +func (s *SSPI) VerifyAuthData(req *http.Request, store DataStore, sess SessionStore) *models.User { if !s.shouldAuthenticate(ctx) { return nil } @@ -75,7 +76,7 @@ func (s *SSPI) VerifyAuthData(ctx *macaron.Context, sess session.Store) *models. return nil } - userInfo, outToken, err := sspiAuth.Authenticate(ctx.Req.Request, ctx.Resp) + userInfo, outToken, err := sspiAuth.Authenticate(req, ctx.Resp) if err != nil { log.Warn("Authentication failed with error: %v\n", err) sspiAuth.AppendAuthenticateHeader(ctx.Resp, outToken) @@ -139,18 +140,18 @@ func (s *SSPI) getConfig() (*models.SSPIConfig, error) { return sources[0].SSPI(), nil } -func (s *SSPI) shouldAuthenticate(ctx *macaron.Context) (shouldAuth bool) { +func (s *SSPI) shouldAuthenticate(req *http.Request) (shouldAuth bool) { shouldAuth = false - path := strings.TrimSuffix(ctx.Req.URL.Path, "/") + path := strings.TrimSuffix(req.URL.Path, "/") if path == "/user/login" { - if ctx.Req.FormValue("user_name") != "" && ctx.Req.FormValue("password") != "" { + if req.FormValue("user_name") != "" && req.FormValue("password") != "" { shouldAuth = false } else if ctx.Req.FormValue("auth_with_sspi") == "1" { shouldAuth = true } - } else if isInternalPath(ctx) { + } else if isInternalPath(req) { shouldAuth = false - } else if isAPIPath(ctx) || isAttachmentDownload(ctx) { + } else if isAPIPath(req) || isAttachmentDownload(req) { shouldAuth = true } return @@ -158,7 +159,7 @@ func (s *SSPI) shouldAuthenticate(ctx *macaron.Context) (shouldAuth bool) { // newUser creates a new user object for the purpose of automatic registration // and populates its name and email with the information present in request headers. -func (s *SSPI) newUser(ctx *macaron.Context, username string, cfg *models.SSPIConfig) (*models.User, error) { +func (s *SSPI) newUser(username string, cfg *models.SSPIConfig) (*models.User, error) { email := gouuid.New().String() + "@localhost.localdomain" user := &models.User{ Name: username, |