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
q[k] = v
}
}
h := url.Values{}
for k, v := range header {
if strings.HasSuffix(strings.ToUpper(k), "-TOKEN") {
......@@ -105,7 +104,7 @@ func (c *AuthCache) verifyDownloadAccess(key AuthCacheKey) AuthReply {
have_entry:
// entry in cache - use it
if auth != nil {
<-auth.ready // make sure it is ready
<-auth.ready // wait untill it is ready
auth.Lock()
auth.Nhit++
......@@ -192,7 +191,8 @@ func (c *AuthCache) askAuthBackend(key AuthCacheKey) AuthReply {
// key.header -> url.Values -> http.Header
hv, err := url.ParseQuery(key.header)
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)
}
header := make(http.Header)
......@@ -248,10 +248,6 @@ func askAuthBackend(u *upstream, project, query string, header *http.Header) Aut
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`
var rawRe = regexp.MustCompile(`/raw/`)
......@@ -268,7 +264,7 @@ func handleGetBlobRaw(w http.ResponseWriter, r *gitRequest) {
refpath := u.Path[rawLoc[1]:]
// 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 == "" {
// access denied - copy auth reply to client in full -
// there are HTTP code and other headers / body relevant for
......@@ -388,7 +384,7 @@ func emitBlob(w http.ResponseWriter, repopath string, refpath string) {
return
}
// close git stdin explicitly, so it exits cleanly
// close git stdin explicitly, so it can exit cleanly
err = queryStdin.Close()
if err != nil {
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