summaryrefslogtreecommitdiffstats
path: root/routers/repo/http.go
diff options
context:
space:
mode:
authorLauris BH <lauris@nix.lv>2018-03-29 04:39:51 +0300
committerLunny Xiao <xiaolunwen@gmail.com>2018-03-29 09:39:51 +0800
commitab5cc6f3a9f2228cefa29b8535492ddacdd99616 (patch)
tree774b35b4e5a1512144f6113c802d670455890aa8 /routers/repo/http.go
parent4c6e170ceb56a8c316e523dd44137fa02ca29735 (diff)
downloadgitea-ab5cc6f3a9f2228cefa29b8535492ddacdd99616.tar.gz
gitea-ab5cc6f3a9f2228cefa29b8535492ddacdd99616.zip
Correctly check http git access rights for reverse proxy authorized users (#3721)
Diffstat (limited to 'routers/repo/http.go')
-rw-r--r--routers/repo/http.go40
1 files changed, 20 insertions, 20 deletions
diff --git a/routers/repo/http.go b/routers/repo/http.go
index 08ccf3ed65..e4e26e4f09 100644
--- a/routers/repo/http.go
+++ b/routers/repo/http.go
@@ -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) {