Skip to content

Commit 8cd6be1

Browse files
lunnyzeripath
andauthored
Remove ReverseProxy authentication from the API (#22219) (#22252)
backport #22219 Since we changed the /api/v1/ routes to disallow session authentication we also removed their reliance on CSRF. However, we left the ReverseProxy authentication here - but this means that POSTs to the API are no longer protected by CSRF. Now, ReverseProxy authentication is a kind of session authentication, and is therefore inconsistent with the removal of session from the API. This PR proposes that we simply remove the ReverseProxy authentication from the API and therefore users of the API must explicitly use tokens or basic authentication. Replace #22077 Close #22221 Close #22077 Signed-off-by: Andrew Thornton <[email protected]> Signed-off-by: Andrew Thornton <[email protected]> Co-authored-by: zeripath <[email protected]>
1 parent f882747 commit 8cd6be1

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

routers/api/v1/api.go

+3-9
Original file line numberDiff line numberDiff line change
@@ -230,13 +230,10 @@ func reqExploreSignIn() func(ctx *context.APIContext) {
230230
}
231231
}
232232

233-
func reqBasicOrRevProxyAuth() func(ctx *context.APIContext) {
233+
func reqBasicAuth() func(ctx *context.APIContext) {
234234
return func(ctx *context.APIContext) {
235-
if ctx.IsSigned && setting.Service.EnableReverseProxyAuth && ctx.Data["AuthedMethod"].(string) == auth.ReverseProxyMethodName {
236-
return
237-
}
238235
if !ctx.Context.IsBasicAuth {
239-
ctx.Error(http.StatusUnauthorized, "reqBasicOrRevProxyAuth", "auth required")
236+
ctx.Error(http.StatusUnauthorized, "reqBasicAuth", "auth required")
240237
return
241238
}
242239
ctx.CheckForOTP()
@@ -595,9 +592,6 @@ func buildAuthGroup() *auth.Group {
595592
&auth.HTTPSign{},
596593
&auth.Basic{}, // FIXME: this should be removed once we don't allow basic auth in API
597594
)
598-
if setting.Service.EnableReverseProxyAuth {
599-
group.Add(&auth.ReverseProxy{})
600-
}
601595
specialAdd(group)
602596

603597
return group
@@ -681,7 +675,7 @@ func Routes() *web.Route {
681675
m.Combo("").Get(user.ListAccessTokens).
682676
Post(bind(api.CreateAccessTokenOption{}), user.CreateAccessToken)
683677
m.Combo("/{id}").Delete(user.DeleteAccessToken)
684-
}, reqBasicOrRevProxyAuth())
678+
}, reqBasicAuth())
685679
}, context_service.UserAssignmentAPI())
686680
})
687681

0 commit comments

Comments
 (0)