Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 11 commits into from
May 29, 2020
8 changes: 7 additions & 1 deletion routers/repo/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -125,8 +126,13 @@ func HTTP(ctx *context.Context) {
return
}

if err := repo.GetOwner(); err != nil {
ctx.ServerError("GetOwner", err)
return
}

// Only public pull don't need auth.
isPublicPull := repoExist && !repo.IsPrivate && isPull
isPublicPull := repoExist && !repo.IsPrivate && repo.Owner.Visibility == structs.VisibleTypePublic && isPull
var (
askAuth = !isPublicPull || setting.Service.RequireSignInView
authUser *models.User
Expand Down