X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/051ad2017b69ca8e438396b461525e485a896321..74df5a58360fe6bcb273480d3ddec507a53b6b2b:/sdk/go/auth/handlers.go diff --git a/sdk/go/auth/handlers.go b/sdk/go/auth/handlers.go index 7b1760f4b8..ad1fa5141a 100644 --- a/sdk/go/auth/handlers.go +++ b/sdk/go/auth/handlers.go @@ -18,7 +18,10 @@ var contextKeyCredentials contextKey = "credentials" // CredentialsFromRequest. func LoadToken(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - next.ServeHTTP(w, r.WithContext(context.WithValue(r.Context(), contextKeyCredentials, CredentialsFromRequest(r)))) + if _, ok := r.Context().Value(contextKeyCredentials).(*Credentials); !ok { + r = r.WithContext(context.WithValue(r.Context(), contextKeyCredentials, CredentialsFromRequest(r))) + } + next.ServeHTTP(w, r) }) }