mirror of
https://codeberg.org/forgejo/forgejo
synced 2024-09-11 01:11:08 +02:00
Ensure correct SSH permissions check for private and restricted users (#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>
This commit is contained in:
parent
c5a408df05
commit
c1110b8671
|
@ -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{
|
||||
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue