Skip to content

Commit 9b4da56

Browse files
lunnyzeripath
andauthored
Remove ReverseProxy authentication from the API (#22219) (#22251)
backport from #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 5583eaa commit 9b4da56

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

routers/api/v1/api.go

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -232,13 +232,10 @@ func reqExploreSignIn() func(ctx *context.APIContext) {
232232
}
233233
}
234234

235-
func reqBasicOrRevProxyAuth() func(ctx *context.APIContext) {
235+
func reqBasicAuth() func(ctx *context.APIContext) {
236236
return func(ctx *context.APIContext) {
237-
if ctx.IsSigned && setting.Service.EnableReverseProxyAuth && ctx.Data["AuthedMethod"].(string) == auth.ReverseProxyMethodName {
238-
return
239-
}
240237
if !ctx.Context.IsBasicAuth {
241-
ctx.Error(http.StatusUnauthorized, "reqBasicOrRevProxyAuth", "auth required")
238+
ctx.Error(http.StatusUnauthorized, "reqBasicAuth", "auth required")
242239
return
243240
}
244241
ctx.CheckForOTP()
@@ -597,9 +594,6 @@ func buildAuthGroup() *auth.Group {
597594
&auth.HTTPSign{},
598595
&auth.Basic{}, // FIXME: this should be removed once we don't allow basic auth in API
599596
)
600-
if setting.Service.EnableReverseProxyAuth {
601-
group.Add(&auth.ReverseProxy{})
602-
}
603597
specialAdd(group)
604598

605599
return group
@@ -689,7 +683,7 @@ func Routes(ctx gocontext.Context) *web.Route {
689683
m.Combo("").Get(user.ListAccessTokens).
690684
Post(bind(api.CreateAccessTokenOption{}), user.CreateAccessToken)
691685
m.Combo("/{id}").Delete(user.DeleteAccessToken)
692-
}, reqBasicOrRevProxyAuth())
686+
}, reqBasicAuth())
693687
}, context_service.UserAssignmentAPI())
694688
})
695689

0 commit comments

Comments
 (0)