Skip to content

Commit

Permalink
Correctly check http git access rights for reverse proxy authorized u…
Browse files Browse the repository at this point in the history
…sers (gogs#3721) (gogs#3743)
  • Loading branch information
lafriks committed Apr 4, 2018
1 parent 6c6d1ff commit 641d481
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions routers/repo/http.go
Expand Up @@ -184,33 +184,33 @@ func HTTP(ctx *context.Context) {
return
}
}
}

if !isPublicPull {
has, err := models.HasAccess(authUser.ID, repo, accessMode)
if err != nil {
ctx.ServerError("HasAccess", err)
return
} else if !has {
if accessMode == models.AccessModeRead {
has, err = models.HasAccess(authUser.ID, repo, models.AccessModeWrite)
if err != nil {
ctx.ServerError("HasAccess2", err)
return
} else if !has {
ctx.HandleText(http.StatusForbidden, "User permission denied")
return
}
} else {
if !isPublicPull {
has, err := models.HasAccess(authUser.ID, repo, accessMode)
if err != nil {
ctx.ServerError("HasAccess", err)
return
} else if !has {
if accessMode == models.AccessModeRead {
has, err = models.HasAccess(authUser.ID, repo, models.AccessModeWrite)
if err != nil {
ctx.ServerError("HasAccess2", err)
return
} else if !has {
ctx.HandleText(http.StatusForbidden, "User permission denied")
return
}
}

if !isPull && repo.IsMirror {
ctx.HandleText(http.StatusForbidden, "mirror repository is read-only")
} else {
ctx.HandleText(http.StatusForbidden, "User permission denied")
return
}
}

if !isPull && repo.IsMirror {
ctx.HandleText(http.StatusForbidden, "mirror repository is read-only")
return
}
}

if !repo.CheckUnitUser(authUser.ID, authUser.IsAdmin, unitType) {
Expand Down

0 comments on commit 641d481

Please sign in to comment.