From: Tom Clegg Date: Tue, 7 May 2019 13:45:58 +0000 (-0400) Subject: 14287: Accept rpc requests without tokens. X-Git-Tag: 2.0.0~282^2~56 X-Git-Url: https://git.arvados.org/arvados.git/commitdiff_plain/a05ec43493addbc26cd7899fbacd3a0155bb0c09 14287: Accept rpc requests without tokens. Arvados-DCO-1.1-Signed-off-by: Tom Clegg --- diff --git a/lib/controller/rpc/conn.go b/lib/controller/rpc/conn.go index 7c23ed170c..9bb3eb33fb 100644 --- a/lib/controller/rpc/conn.go +++ b/lib/controller/rpc/conn.go @@ -71,10 +71,15 @@ func (conn *Conn) requestAndDecode(ctx context.Context, dst interface{}, ep arva tokens, err := conn.tokenProvider(ctx) if err != nil { return err - } else if len(tokens) == 0 { - return fmt.Errorf("bug: token provider returned no tokens and no error") + } else if len(tokens) > 0 { + ctx = context.WithValue(ctx, "Authorization", "Bearer "+tokens[0]) + } else { + // Use a non-empty auth string to ensure we override + // any default token set on aClient -- and to avoid + // having the remote prompt us to send a token by + // responding 401. + ctx = context.WithValue(ctx, "Authorization", "Bearer -") } - ctx = context.WithValue(ctx, "Authorization", "Bearer "+tokens[0]) // Encode opts to JSON and decode from there to a // map[string]interface{}, so we can munge the query params