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) (#17373)

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: Andrew Thornton <art27@cantab.net>
  • Loading branch information
6543 and zeripath committed Oct 20, 2021
1 parent 79a3d27 commit 79f0b1a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion routers/private/serv.go
Expand Up @@ -278,7 +278,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 Down

0 comments on commit 79f0b1a

Please sign in to comment.