Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion identityclient/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ func (c *Client) IssueServiceToken(
}
request.Header.Set("Content-Type", "application/json")
if strings.TrimSpace(c.bootstrapKey) != "" {
request.Header.Set("X-Identity-Bootstrap-Key", c.bootstrapKey)
request.Header.Set("Authorization", "Bearer "+c.bootstrapKey)
}

response, err := c.httpClient.Do(request)
Expand Down
9 changes: 9 additions & 0 deletions identityclient/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,12 @@ func TestResolveServiceTokenIssuesAndCachesByScopeSet(t *testing.T) {
var identityCalls atomic.Int32
identityServer := testutil.NewTestServer(t, http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
identityCalls.Add(1)
if got := r.Header.Get("Authorization"); got != "Bearer identity-bootstrap-key" {
t.Fatalf("expected bearer bootstrap authorization, got %q", got)
}
if got := r.Header.Get("X-Identity-Bootstrap-Key"); got != "" {
t.Fatalf("expected legacy bootstrap header to be absent, got %q", got)
}
testutil.WriteJSON(t, w, http.StatusCreated, map[string]any{
"token": "identity-service-token",
"token_type": "Bearer",
Expand Down Expand Up @@ -553,6 +559,9 @@ func TestIssueServiceTokenAllowsMTLSWithoutBootstrapKey(t *testing.T) {
t.Parallel()

identityServer := testutil.NewTestServer(t, http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if got := r.Header.Get("Authorization"); got != "" {
t.Fatalf("expected no authorization header without a bootstrap key, got %q", got)
}
if got := r.Header.Get("X-Identity-Bootstrap-Key"); got != "" {
t.Fatalf("expected no bootstrap key header, got %q", got)
}
Expand Down
Loading