diff options
author | Thibault Meyer <0xbaadf00d@users.noreply.github.com> | 2016-12-22 07:42:04 +0100 |
---|---|---|
committer | 无闻 <u@gogs.io> | 2016-12-22 01:42:04 -0500 |
commit | c47fbc629bec5b4c213ddff24e96c20ed8f4ca74 (patch) | |
tree | 25f404cf44674c090fca73ae46dda9d6dfc5ee1b /routers/repo/http.go | |
parent | d04b19545db513c31d86d503046f51ba780e4038 (diff) |
Feature #2583: Disable HTTP cloning (#3667)
* Can disable GIT interactions by HTTP protocol
* rename variable + fix wiki link
* missing space
Diffstat (limited to 'routers/repo/http.go')
-rw-r--r-- | routers/repo/http.go | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/routers/repo/http.go b/routers/repo/http.go index 80afcec4..65a5d5fa 100644 --- a/routers/repo/http.go +++ b/routers/repo/http.go @@ -479,6 +479,11 @@ func HTTPBackend(ctx *context.Context, cfg *serviceConfig) http.HandlerFunc { for _, route := range routes { r.URL.Path = strings.ToLower(r.URL.Path) // blue: In case some repo name has upper case name if m := route.reg.FindStringSubmatch(r.URL.Path); m != nil { + if setting.Repository.DisableHTTPGit { + w.WriteHeader(http.StatusForbidden) + w.Write([]byte("Interacting with repositories by HTTP protocol is not allowed")) + return + } if route.method != r.Method { if r.Proto == "HTTP/1.1" { w.WriteHeader(http.StatusMethodNotAllowed) |