Skip to content

Commit 83640c4

Browse files
authored
Remove ReverseProxy authentication from the API (#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]>
1 parent 814b44a commit 83640c4

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()
@@ -598,9 +595,6 @@ func buildAuthGroup() *auth.Group {
598595
&auth.HTTPSign{},
599596
&auth.Basic{}, // FIXME: this should be removed once we don't allow basic auth in API
600597
)
601-
if setting.Service.EnableReverseProxyAuth {
602-
group.Add(&auth.ReverseProxy{})
603-
}
604598
specialAdd(group)
605599

606600
return group
@@ -690,7 +684,7 @@ func Routes(ctx gocontext.Context) *web.Route {
690684
m.Combo("").Get(user.ListAccessTokens).
691685
Post(bind(api.CreateAccessTokenOption{}), user.CreateAccessToken)
692686
m.Combo("/{id}").Delete(user.DeleteAccessToken)
693-
}, reqBasicOrRevProxyAuth())
687+
}, reqBasicAuth())
694688
}, context_service.UserAssignmentAPI())
695689
})
696690

0 commit comments

Comments
 (0)