Skip to content

Commit

Permalink
Ensure correct SSH permissions check for private and restricted users (
Browse files Browse the repository at this point in the history
…#17370)

Repositories owned by private users and organisations and pulls by restricted users
need to have permissions checked. Previously Serv would simply assumed that if the
user could log in and the repository was not private then it would be visible.

Fix #17364

Signed-off-by: Andrew Thornton <art27@cantab.net>

Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
  • Loading branch information
3 people authored Oct 20, 2021
1 parent c5a408d commit c1110b8
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions routers/private/serv.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,12 @@ func ServCommand(ctx *context.PrivateContext) {
}

// Permissions checking:
if repoExist && (mode > models.AccessModeRead || repo.IsPrivate || setting.Service.RequireSignInView) {
if repoExist &&
(mode > models.AccessModeRead ||
repo.IsPrivate ||
owner.Visibility.IsPrivate() ||
user.IsRestricted ||
setting.Service.RequireSignInView) {
if key.Type == models.KeyTypeDeploy {
if deployKey.Mode < mode {
ctx.JSON(http.StatusUnauthorized, private.ErrServCommand{
Expand All @@ -289,7 +294,7 @@ func ServCommand(ctx *context.PrivateContext) {
return
}
} else {
// Because of special ref "refs/for" .. , need delay write permission check
// Because of the special ref "refs/for" we will need to delay write permission check
if git.SupportProcReceive && unitType == models.UnitTypeCode {
mode = models.AccessModeRead
}
Expand Down

0 comments on commit c1110b8

Please sign in to comment.