aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/auth
diff options
context:
space:
mode:
authorGreg Steuck <gnezdo@google.com>2021-07-28 15:34:03 -0700
committerDmitry Vyukov <dvyukov@google.com>2021-07-30 18:21:17 +0200
commit6c236867ce33c0c16b102e02a08226d7eb9b2046 (patch)
treebe81602e5bbe634e223bdc2bfc97049dd7f8a57e /pkg/auth
parent75047cf943db20755af0bf9ce3af5502b4040b70 (diff)
syz-manager: support oauth when calling syz-hub
Permit empty hub_key to indicate oauth.
Diffstat (limited to 'pkg/auth')
-rw-r--r--pkg/auth/jwt.go5
1 files changed, 3 insertions, 2 deletions
diff --git a/pkg/auth/jwt.go b/pkg/auth/jwt.go
index 3e2313d11..f6d219323 100644
--- a/pkg/auth/jwt.go
+++ b/pkg/auth/jwt.go
@@ -101,7 +101,8 @@ func MakeCache(ctor func(method, url string, body io.Reader) (*http.Request, err
// Get returns a potentially cached value of the token or renews as
// necessary. The now parameter provides the current time for cache
-// expiration.
+// expiration. The returned value is suitable for Authorization header
+// and syz-hub Key requests.
func (cache *TokenCache) Get(now time.Time) (string, error) {
cache.lock.Lock()
defer cache.lock.Unlock()
@@ -118,5 +119,5 @@ func (cache *TokenCache) Get(now time.Time) (string, error) {
}
cache.token = t
}
- return cache.token.value, nil
+ return "Bearer " + cache.token.value, nil
}