Skip to content

Commit 02fa329

Browse files
authored
Fix missing authorization check on pull for public repos of private/limited org (#11656)
Fixes #11651
1 parent 0d9f9f7 commit 02fa329

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

routers/repo/http.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import (
2929
"code.gitea.io/gitea/modules/log"
3030
"code.gitea.io/gitea/modules/process"
3131
"code.gitea.io/gitea/modules/setting"
32+
"code.gitea.io/gitea/modules/structs"
3233
"code.gitea.io/gitea/modules/timeutil"
3334
repo_service "code.gitea.io/gitea/services/repository"
3435
)
@@ -135,6 +136,16 @@ func HTTP(ctx *context.Context) {
135136
environ []string
136137
)
137138

139+
// don't allow anonymous pulls if organization is not public
140+
if isPublicPull {
141+
if err := repo.GetOwner(); err != nil {
142+
ctx.ServerError("GetOwner", err)
143+
return
144+
}
145+
146+
askAuth = askAuth || (repo.Owner.Visibility != structs.VisibleTypePublic)
147+
}
148+
138149
// check access
139150
if askAuth {
140151
authUsername = ctx.Req.Header.Get(setting.ReverseProxyAuthUser)

0 commit comments

Comments
 (0)