Skip to content

Commit dc5e4ef

Browse files
zeripathlunny
authored andcommitted
Remove ReverseProxy authentication from the API (go-gitea#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 go-gitea#22077 Close go-gitea#22221 Close go-gitea#22077 Signed-off-by: Andrew Thornton <art27@cantab.net>
1 parent 4845093 commit dc5e4ef

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)