X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/a8caa6e1b359893e99226a8b21f356eee6edd529..b9276721177e8aa6710ed7203f1142f9062af81c:/sdk/go/auth/auth.go diff --git a/sdk/go/auth/auth.go b/sdk/go/auth/auth.go index ca4eb948b1..ea492430e4 100644 --- a/sdk/go/auth/auth.go +++ b/sdk/go/auth/auth.go @@ -1,3 +1,7 @@ +// Copyright (C) The Arvados Authors. All rights reserved. +// +// SPDX-License-Identifier: Apache-2.0 + package auth import ( @@ -35,13 +39,13 @@ var DecodeTokenCookie func(string) ([]byte, error) = base64.URLEncoding.DecodeSt func (a *Credentials) LoadTokensFromHTTPRequest(r *http.Request) { // Load plain token from "Authorization: OAuth2 ..." header // (typically used by smart API clients) - if toks := strings.SplitN(r.Header.Get("Authorization"), " ", 2); len(toks) == 2 && toks[0] == "OAuth2" { + if toks := strings.SplitN(r.Header.Get("Authorization"), " ", 2); len(toks) == 2 && (toks[0] == "OAuth2" || toks[0] == "Bearer") { a.Tokens = append(a.Tokens, toks[1]) } // Load base64-encoded token from "Authorization: Basic ..." // header (typically used by git via credential helper) - if _, password, ok := BasicAuth(r); ok { + if _, password, ok := r.BasicAuth(); ok { a.Tokens = append(a.Tokens, password) }