diff options
| author | Greg Steuck <greg@nest.cx> | 2021-07-10 08:51:25 -0700 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2021-07-14 07:16:41 +0200 |
| commit | 6172cc679a71826349b603382cb18a441f16438f (patch) | |
| tree | 8cca4c98128564c276de0a1a7d8b6f58e16b64dd /dashboard/dashapi/dashapi.go | |
| parent | cfc934a81713b26518f1ae0fa94900a2da77553b (diff) | |
dashboard/dashapi: implement client-side JWT token authorization
Diffstat (limited to 'dashboard/dashapi/dashapi.go')
| -rw-r--r-- | dashboard/dashapi/dashapi.go | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/dashboard/dashapi/dashapi.go b/dashboard/dashapi/dashapi.go index cdd557994..d36adaa68 100644 --- a/dashboard/dashapi/dashapi.go +++ b/dashboard/dashapi/dashapi.go @@ -40,8 +40,17 @@ type ( RequestLogger func(msg string, args ...interface{}) ) +// key == "" indicates that the ambient GCE service account authority +// should be used as a bearer token. func NewCustom(client, addr, key string, ctor RequestCtor, doer RequestDoer, logger RequestLogger, errorHandler func(error)) (*Dashboard, error) { + if key == "" { + token, err := retrieveJwtToken(ctor, doer) + if err != nil { + return nil, err + } + doer = atachJwtToken(ctor, doer, token) + } return &Dashboard{ Client: client, Addr: addr, |
