Skip to content

Commit da28335

Browse files
committed
remove DisableCrossOriginProtection
1 parent 897ff51 commit da28335

File tree

3 files changed

+8
-11
lines changed

3 files changed

+8
-11
lines changed

routers/common/auth.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ func AuthShared(ctx *context.Base, sessionStore auth_service.SessionStore, authM
3838

3939
// VerifyOptions contains required or check options
4040
type VerifyOptions struct {
41-
SignInRequired bool
42-
SignOutRequired bool
43-
AdminRequired bool
44-
DisableCrossOriginProtection bool
41+
SignInRequired bool
42+
SignOutRequired bool
43+
AdminRequired bool
4544
}

routers/web/githttp.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,5 @@ func addOwnerRepoGitHTTPRouters(m *web.Router) {
2222
m.Methods("GET,OPTIONS", "/objects/{head:[0-9a-f]{2}}/{hash:[0-9a-f]{38,62}}", repo.GetLooseObject)
2323
m.Methods("GET,OPTIONS", "/objects/pack/pack-{file:[0-9a-f]{40,64}}.pack", repo.GetPackFile)
2424
m.Methods("GET,OPTIONS", "/objects/pack/pack-{file:[0-9a-f]{40,64}}.idx", repo.GetIdxFile)
25-
}, optSignInAnyOrigin, repo.HTTPGitEnabledHandler, repo.CorsHandler(), context.UserAssignmentWeb())
25+
}, repo.HTTPGitEnabledHandler, repo.CorsHandler(), context.UserAssignmentWeb())
2626
}

routers/web/web.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ func verifyAuthWithOptions(options *common.VerifyOptions) func(ctx *context.Cont
178178
return
179179
}
180180

181-
if !options.SignOutRequired && !options.DisableCrossOriginProtection {
181+
if !options.SignOutRequired {
182182
if err := crossOrginProtection.Check(ctx.Req); err != nil {
183183
http.Error(ctx.Resp, err.Error(), http.StatusForbidden)
184184
return
@@ -292,8 +292,6 @@ func Routes() *web.Router {
292292
return routes
293293
}
294294

295-
var optSignInAnyOrigin = verifyAuthWithOptions(&common.VerifyOptions{DisableCrossOriginProtection: true})
296-
297295
// registerWebRoutes register routes
298296
func registerWebRoutes(m *web.Router) {
299297
// required to be signed in or signed out
@@ -489,7 +487,7 @@ func registerWebRoutes(m *web.Router) {
489487
m.Post("/-/markup", reqSignIn, web.Bind(structs.MarkupOption{}), misc.Markup)
490488

491489
m.Get("/-/web-theme/list", misc.WebThemeList)
492-
m.Post("/-/web-theme/apply", optSignInAnyOrigin, misc.WebThemeApply)
490+
m.Post("/-/web-theme/apply", misc.WebThemeApply)
493491

494492
m.Group("/explore", func() {
495493
m.Get("", func(ctx *context.Context) {
@@ -572,7 +570,7 @@ func registerWebRoutes(m *web.Router) {
572570
m.Methods("POST, OPTIONS", "/access_token", web.Bind(forms.AccessTokenForm{}), auth.AccessTokenOAuth)
573571
m.Methods("GET, OPTIONS", "/keys", auth.OIDCKeys)
574572
m.Methods("POST, OPTIONS", "/introspect", web.Bind(forms.IntrospectTokenForm{}), auth.IntrospectOAuth)
575-
}, optionsCorsHandler(), optSignInAnyOrigin)
573+
}, optionsCorsHandler())
576574
}, oauth2Enabled)
577575

578576
m.Group("/user/settings", func() {
@@ -1655,7 +1653,7 @@ func registerWebRoutes(m *web.Router) {
16551653
m.Post("/action/{action:accept_transfer|reject_transfer}", reqSignIn, repo.ActionTransfer)
16561654
}, optSignIn, context.RepoAssignment)
16571655

1658-
common.AddOwnerRepoGitLFSRoutes(m, optSignInAnyOrigin, lfsServerEnabled) // "/{username}/{reponame}/{lfs-paths}": git-lfs support
1656+
common.AddOwnerRepoGitLFSRoutes(m, lfsServerEnabled) // "/{username}/{reponame}/{lfs-paths}": git-lfs support
16591657

16601658
addOwnerRepoGitHTTPRouters(m) // "/{username}/{reponame}/{git-paths}": git http support
16611659

0 commit comments

Comments
 (0)