fix(licenses): licensed private repos allow release viewing for signed-in users #422

Merged
jmiller merged 1 commits from dev into main 2026-06-02 14:52:35 +00:00
2 changed files with 21 additions and 6 deletions
+20 -6
View File
@@ -435,15 +435,29 @@ func repoAssignmentLegacy(ctx *Context, data *repoAssignmentPrepareDataStruct) {
EarlyResponseForGoGetMeta(ctx)
return
}
// For signed-in users, show "access denied" instead of 404
// so they know the repo exists but they lack permission.
// Anonymous users still get 404 to prevent repo enumeration.
// Check if licensing is enabled — licensed repos allow signed-in
// users to view releases even without repo membership.
if ctx.IsSigned {
ctx.HTTPError(http.StatusForbidden, "You do not have permission to access this repository")
orgCfg, _ := licenses_model.GetOrgConfig(ctx, repo.OwnerID)
repoCfg, _ := licenses_model.GetRepoConfig(ctx, repo.ID)
licensingEnabled := (orgCfg != nil && orgCfg.LicensingEnabled) ||
(repoCfg != nil && repoCfg.LicensingEnabled)
if licensingEnabled {
// Grant read-only access with downloads hidden.
ctx.Data["LicensingEnabled"] = licensingEnabled
ctx.Data["HideReleaseDownloads"] = true
ctx.Data["LicensedReadOnly"] = true
// Continue — don't block access.
} else {
ctx.HTTPError(http.StatusForbidden, "You do not have permission to access this repository")
return
}
} else {
ctx.NotFound(nil)
return
}
ctx.NotFound(nil)
return
}
ctx.Data["Permission"] = &ctx.Repo.Permission
+1
View File
@@ -53,3 +53,4 @@ func RepoAssignmentPublicFeed() func(ctx *Context) {
log.Trace("Public feed access: %s/%s", ownerName, repoName)
}
}