Commit 0ed2cd01 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent e5673020
Pipeline #150 failed with stage
...@@ -82,7 +82,6 @@ func (c *AuthCache) VerifyDownloadAccess(project string, query url.Values, heade ...@@ -82,7 +82,6 @@ func (c *AuthCache) VerifyDownloadAccess(project string, query url.Values, heade
q[k] = v q[k] = v
} }
} }
h := url.Values{} h := url.Values{}
for k, v := range header { for k, v := range header {
if strings.HasSuffix(strings.ToUpper(k), "-TOKEN") { if strings.HasSuffix(strings.ToUpper(k), "-TOKEN") {
...@@ -105,7 +104,7 @@ func (c *AuthCache) verifyDownloadAccess(key AuthCacheKey) AuthReply { ...@@ -105,7 +104,7 @@ func (c *AuthCache) verifyDownloadAccess(key AuthCacheKey) AuthReply {
have_entry: have_entry:
// entry in cache - use it // entry in cache - use it
if auth != nil { if auth != nil {
<-auth.ready // make sure it is ready <-auth.ready // wait untill it is ready
auth.Lock() auth.Lock()
auth.Nhit++ auth.Nhit++
...@@ -192,7 +191,8 @@ func (c *AuthCache) askAuthBackend(key AuthCacheKey) AuthReply { ...@@ -192,7 +191,8 @@ func (c *AuthCache) askAuthBackend(key AuthCacheKey) AuthReply {
// key.header -> url.Values -> http.Header // key.header -> url.Values -> http.Header
hv, err := url.ParseQuery(key.header) hv, err := url.ParseQuery(key.header)
if err != nil { if err != nil {
// we prepared key.header ourselves via url-encoding in XXX. It must be ok // we prepared key.header ourselves via url-encoding in AuthCache.VerifyDownloadAccess().
// It must be ok
panic(err) panic(err)
} }
header := make(http.Header) header := make(http.Header)
...@@ -248,10 +248,6 @@ func askAuthBackend(u *upstream, project, query string, header *http.Header) Aut ...@@ -248,10 +248,6 @@ func askAuthBackend(u *upstream, project, query string, header *http.Header) Aut
return authReply return authReply
} }
func verifyDownloadAccess(u *upstream, project string, query url.Values, header http.Header) AuthReply {
return u.authCache.VerifyDownloadAccess(project, query, header)
}
// HTTP handler for `.../raw/<ref>/path` // HTTP handler for `.../raw/<ref>/path`
var rawRe = regexp.MustCompile(`/raw/`) var rawRe = regexp.MustCompile(`/raw/`)
...@@ -268,7 +264,7 @@ func handleGetBlobRaw(w http.ResponseWriter, r *gitRequest) { ...@@ -268,7 +264,7 @@ func handleGetBlobRaw(w http.ResponseWriter, r *gitRequest) {
refpath := u.Path[rawLoc[1]:] refpath := u.Path[rawLoc[1]:]
// Query download access auth for this project // Query download access auth for this project
authReply := verifyDownloadAccess(r.u, project, u.Query(), r.Request.Header) authReply := r.u.authCache.VerifyDownloadAccess(project, u.Query(), r.Request.Header)
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
...@@ -388,7 +384,7 @@ func emitBlob(w http.ResponseWriter, repopath string, refpath string) { ...@@ -388,7 +384,7 @@ func emitBlob(w http.ResponseWriter, repopath string, refpath string) {
return return
} }
// close git stdin explicitly, so it exits cleanly // close git stdin explicitly, so it can exit cleanly
err = queryStdin.Close() err = queryStdin.Close()
if err != nil { if err != nil {
logError(fmt.Errorf("queryStdin.Close: %v", err)) logError(fmt.Errorf("queryStdin.Close: %v", err))
......
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