Fix missing authorization check on pull for public repos of private/limited org (#11656) (#11682)

Fixes #11651

(cherry picked from commit 02fa329a7c)
This commit is contained in:
Cirno the Strongest 2020-05-29 22:00:22 +02:00 committed by GitHub
parent d9db28a25a
commit 6ad0d0a1b9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 0 deletions

View File

@ -29,6 +29,7 @@ import (
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/process"
"code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/modules/structs"
"code.gitea.io/gitea/modules/timeutil"
repo_service "code.gitea.io/gitea/services/repository"
)
@ -135,6 +136,16 @@ func HTTP(ctx *context.Context) {
environ []string
)
// don't allow anonymous pulls if organization is not public
if isPublicPull {
if err := repo.GetOwner(); err != nil {
ctx.ServerError("GetOwner", err)
return
}
askAuth = askAuth || (repo.Owner.Visibility != structs.VisibleTypePublic)
}
// check access
if askAuth {
authUsername = ctx.Req.Header.Get(setting.ReverseProxyAuthUser)