SECURITY: fix release download gating and require login for actions #415
+1
-1
@@ -1620,7 +1620,7 @@ func registerWebRoutes(m *web.Router, webAuth *AuthMiddleware) {
|
||||
m.Group("/workflows/{workflow_name}", func() {
|
||||
m.Get("/badge.svg", webAuth.AllowBasic, webAuth.AllowOAuth2, actions.GetWorkflowBadge)
|
||||
})
|
||||
}, optSignIn, context.RepoAssignment, repo.MustBeNotEmpty, reqRepoActionsReader, actions.MustEnableActions)
|
||||
}, reqSignIn, context.RepoAssignment, repo.MustBeNotEmpty, reqRepoActionsReader, actions.MustEnableActions)
|
||||
// end "/{username}/{reponame}/actions"
|
||||
|
||||
m.Group("/{username}/{reponame}/wiki", func() {
|
||||
|
||||
@@ -628,10 +628,29 @@ func repoAssignmentPrepareTemplateData(ctx *Context, data *repoAssignmentPrepare
|
||||
feedVis = repoUpdateCfg.FeedVisibility
|
||||
}
|
||||
ctx.Data["FeedVisibility"] = feedVis
|
||||
// Only "hidden" mode requires login. "no-download" shows page but hides files.
|
||||
// Only "hidden" mode requires login for the page itself.
|
||||
ctx.Data["ReleasesRequireLogin"] = licensingEnabled && feedVis == "hidden"
|
||||
// Hide download attachments for anonymous users in "no-download" mode.
|
||||
ctx.Data["HideReleaseDownloads"] = licensingEnabled && feedVis == "no-download" && !ctx.IsSigned
|
||||
|
||||
// Determine download gating mode.
|
||||
downloadGating := "none"
|
||||
if orgCfg != nil && orgCfg.DownloadGating != "" {
|
||||
downloadGating = orgCfg.DownloadGating
|
||||
}
|
||||
if repoUpdateCfg != nil && repoUpdateCfg.DownloadGating != "" {
|
||||
downloadGating = repoUpdateCfg.DownloadGating
|
||||
}
|
||||
ctx.Data["DownloadGating"] = downloadGating
|
||||
|
||||
// Hide download links on release page when:
|
||||
// - licensing enabled AND feed visibility is "no-download" (anonymous only), OR
|
||||
// - licensing enabled AND download gating is active AND user not signed in
|
||||
hideDownloads := false
|
||||
if licensingEnabled && !ctx.IsSigned {
|
||||
if feedVis == "no-download" || feedVis == "hidden" || downloadGating != "none" {
|
||||
hideDownloads = true
|
||||
}
|
||||
}
|
||||
ctx.Data["HideReleaseDownloads"] = hideDownloads
|
||||
ctx.Data["IsRepoAdmin"] = ctx.Repo.Permission.IsAdmin()
|
||||
ctx.Data["IsSiteAdmin"] = ctx.IsUserSiteAdmin()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user