Fallback to service token
This commit is contained in:
parent
bd70820b6b
commit
36386354d7
@ -131,11 +131,14 @@ func (g *grpcClient) call(ctx context.Context, node *registry.Node, req client.R
|
|||||||
// set the content type for the request
|
// set the content type for the request
|
||||||
header["x-content-type"] = req.ContentType()
|
header["x-content-type"] = req.ContentType()
|
||||||
|
|
||||||
// if the caller specifies using service privelages, and the client
|
// if the caller specifies using service token or no token
|
||||||
// has auth set, override the authorization header
|
// was passed with the request, set the service token
|
||||||
if opts.ServiceToken && g.opts.Auth != nil && g.opts.Auth.Options().Token != nil {
|
var srvToken string
|
||||||
t := g.opts.Auth.Options().Token
|
if g.opts.Auth != nil && g.opts.Auth.Options().Token != nil {
|
||||||
header["authorization"] = auth.BearerScheme + t.Token
|
srvToken = g.opts.Auth.Options().Token.Token
|
||||||
|
}
|
||||||
|
if (opts.ServiceToken || len(header["authorization"]) == 0) && len(srvToken) > 0 {
|
||||||
|
header["authorization"] = auth.BearerScheme + srvToken
|
||||||
}
|
}
|
||||||
|
|
||||||
// fall back to using the authorization token set in config,
|
// fall back to using the authorization token set in config,
|
||||||
|
Loading…
Reference in New Issue
Block a user