X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/f29266f2fd9d2713f6b2666d13d4f706630b7215..e634af988c6bbf23ebe2f6645360a1237182a85f:/services/arv-git-httpd/auth_handler.go diff --git a/services/arv-git-httpd/auth_handler.go b/services/arv-git-httpd/auth_handler.go index 3b3032afda..13706ae3e8 100644 --- a/services/arv-git-httpd/auth_handler.go +++ b/services/arv-git-httpd/auth_handler.go @@ -14,22 +14,30 @@ import ( "sync" "time" - "git.curoverse.com/arvados.git/sdk/go/arvadosclient" - "git.curoverse.com/arvados.git/sdk/go/auth" - "git.curoverse.com/arvados.git/sdk/go/httpserver" + "git.arvados.org/arvados.git/sdk/go/arvados" + "git.arvados.org/arvados.git/sdk/go/arvadosclient" + "git.arvados.org/arvados.git/sdk/go/auth" + "git.arvados.org/arvados.git/sdk/go/httpserver" ) type authHandler struct { handler http.Handler clientPool *arvadosclient.ClientPool + cluster *arvados.Cluster setupOnce sync.Once } func (h *authHandler) setup() { - ac, err := arvadosclient.New(&theConfig.Client) + client, err := arvados.NewClientFromConfig(h.cluster) if err != nil { log.Fatal(err) } + + ac, err := arvadosclient.New(client) + if err != nil { + log.Fatalf("Error setting up arvados client prototype %v", err) + } + h.clientPool = &arvadosclient.ClientPool{Prototype: ac} } @@ -40,7 +48,7 @@ func (h *authHandler) ServeHTTP(wOrig http.ResponseWriter, r *http.Request) { var statusText string var apiToken string var repoName string - var validApiToken bool + var validAPIToken bool w := httpserver.WrapResponseWriter(wOrig) @@ -80,7 +88,7 @@ func (h *authHandler) ServeHTTP(wOrig http.ResponseWriter, r *http.Request) { // If the given password is a valid token, log the first 10 characters of the token. // Otherwise: log the string if a password is given, else an empty string. passwordToLog := "" - if !validApiToken { + if !validAPIToken { if len(apiToken) > 0 { passwordToLog = "" } @@ -125,7 +133,7 @@ func (h *authHandler) ServeHTTP(wOrig http.ResponseWriter, r *http.Request) { statusCode, statusText = http.StatusInternalServerError, err.Error() return } - validApiToken = true + validAPIToken = true if repoUUID == "" { statusCode, statusText = http.StatusNotFound, "not found" return @@ -161,7 +169,7 @@ func (h *authHandler) ServeHTTP(wOrig http.ResponseWriter, r *http.Request) { "/" + repoName + "/.git", } for _, dir := range tryDirs { - if fileInfo, err := os.Stat(theConfig.RepoRoot + dir); err != nil { + if fileInfo, err := os.Stat(h.cluster.Git.Repositories + dir); err != nil { if !os.IsNotExist(err) { statusCode, statusText = http.StatusInternalServerError, err.Error() return @@ -173,7 +181,7 @@ func (h *authHandler) ServeHTTP(wOrig http.ResponseWriter, r *http.Request) { } if rewrittenPath == "" { log.Println("WARNING:", repoUUID, - "git directory not found in", theConfig.RepoRoot, tryDirs) + "git directory not found in", h.cluster.Git.Repositories, tryDirs) // We say "content not found" to disambiguate from the // earlier "API says that repo does not exist" error. statusCode, statusText = http.StatusNotFound, "content not found"