Commit ad2b32f0 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent d33010bb
Pipeline #141 failed with stage
...@@ -14,6 +14,7 @@ import ( ...@@ -14,6 +14,7 @@ import (
"log" "log"
"net/http" "net/http"
"net/http/httptest" "net/http/httptest"
"net/url"
"regexp" "regexp"
"strings" "strings"
"sync" "sync"
...@@ -220,17 +221,25 @@ var rawRe = regexp.MustCompile(`/raw/`) ...@@ -220,17 +221,25 @@ var rawRe = regexp.MustCompile(`/raw/`)
func handleGetBlobRaw(w http.ResponseWriter, r *gitRequest) { func handleGetBlobRaw(w http.ResponseWriter, r *gitRequest) {
// Extract project & refpath // Extract project & refpath
// <project>/raw/branch/file -> <project>, branch/file // <project>/raw/branch/file -> <project>, branch/file
url := r.Request.URL u := r.Request.URL // XXX naming
rawLoc := rawRe.FindStringIndex(url.Path) rawLoc := rawRe.FindStringIndex(u.Path)
if rawLoc == nil { if rawLoc == nil {
fail500(w, "extract project name", nil) // XXX err=nil fail500(w, "extract project name", nil) // XXX err=nil
return return
} }
project := url.Path[:rawLoc[0]] project := u.Path[:rawLoc[0]]
refpath := url.Path[rawLoc[1]:] refpath := u.Path[rawLoc[1]:]
// Extract only tokens from query
query := url.Values{}
for k, v := range u.Query() {
if strings.HasSuffix(k, "_token") {
query[k] = v
}
}
// Query download access auth for this project // Query download access auth for this project
authReply := verifyDownloadAccess(r.u, project, url.RawQuery) authReply := verifyDownloadAccess(r.u, project, query.Encode())
if authReply.RepoPath == "" { if authReply.RepoPath == "" {
// access denied - copy auth reply to client in full - // access denied - copy auth reply to client in full -
// there are HTTP code and other headers / body relevant for // there are HTTP code and other headers / body relevant for
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment