Skip to content

Commit b78448e

Browse files
zeripathtechknowlogicklafriks
authored
Skip SSPI authentication attempts for /api/internal (#12556)
* Skip SSPI authentication attempts for /api/internal SSPI fails badly on authentication attempts to /api/internal which it can never succesfully authenticate. Fix #11260 Signed-off-by: Andrew Thornton <[email protected]> * Update oauth2.go Co-authored-by: techknowlogick <[email protected]> Co-authored-by: Lauris BH <[email protected]>
1 parent d4e35b9 commit b78448e

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

modules/auth/sso/oauth2.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ func (o *OAuth2) VerifyAuthData(ctx *macaron.Context, sess session.Store) *model
121121
return nil
122122
}
123123

124-
if !isAPIPath(ctx) && !isAttachmentDownload(ctx) {
124+
if isInternalPath(ctx) || !isAPIPath(ctx) && !isAttachmentDownload(ctx) {
125125
return nil
126126
}
127127

modules/auth/sso/sso.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,11 @@ func isAPIPath(ctx *macaron.Context) bool {
100100
return strings.HasPrefix(ctx.Req.URL.Path, "/api/")
101101
}
102102

103+
// isInternalPath returns true if the specified URL is an internal API path
104+
func isInternalPath(ctx *macaron.Context) bool {
105+
return strings.HasPrefix(ctx.Req.URL.Path, "/api/internal/")
106+
}
107+
103108
// isAttachmentDownload check if request is a file download (GET) with URL to an attachment
104109
func isAttachmentDownload(ctx *macaron.Context) bool {
105110
return strings.HasPrefix(ctx.Req.URL.Path, "/attachments/") && ctx.Req.Method == "GET"

modules/auth/sso/sspi_windows.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,8 @@ func (s *SSPI) shouldAuthenticate(ctx *macaron.Context) (shouldAuth bool) {
148148
} else if ctx.Req.FormValue("auth_with_sspi") == "1" {
149149
shouldAuth = true
150150
}
151+
} else if isInternalPath(ctx) {
152+
shouldAuth = false
151153
} else if isAPIPath(ctx) || isAttachmentDownload(ctx) {
152154
shouldAuth = true
153155
}

0 commit comments

Comments
 (0)