Can disable GIT interactions by HTTP protocol

This commit is contained in:
Thibault Meyer 2016-09-18 10:54:33 +02:00
parent 7e15ff9486
commit 9d66497abc
No known key found for this signature in database
GPG key ID: C52D76D2CCF24933
7 changed files with 40 additions and 13 deletions

View file

@ -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)