Skip to content

Canonicalize OAuth Bearer scheme when building Authorization header#821

Merged
renaudhartert-db merged 7 commits into
mainfrom
canonicalize-oauth-bearer-header
Jun 8, 2026
Merged

Canonicalize OAuth Bearer scheme when building Authorization header#821
renaudhartert-db merged 7 commits into
mainfrom
canonicalize-oauth-bearer-header

Conversation

@renaudhartert-db

Copy link
Copy Markdown
Contributor

Identity providers may return token_type in any case (e.g. bearer, BEARER) per RFC 6749/6750, but some downstream servers and proxies reject anything other than the canonical Bearer. This caused intermittent auth failures depending on the IdP's response casing.

Adds Token.getCanonicalTokenType(), which returns Bearer whenever tokenType case-insensitively matches bearer and otherwise returns the original value untouched. Routes the three Authorization header construction sites through the new helper: OAuthHeaderFactory.fromTokenSource, AzureCliCredentialsProvider, and ServingEndpointsDataPlaneImpl. Non-Bearer schemes (e.g. MAC, custom) are unchanged.

Original change authored by @mkazia in #788; this branch is the same change rebased onto current main with the changelog conflict resolved, opened from origin so CI runs with OIDC. #788 can be closed once this merges.

Tests: TokenTest and OAuthHeaderFactoryTest cover Bearer casing normalization, non-Bearer pass-through, and the assembled Authorization: Bearer <token> header; 12 passed locally against current main.

mkazia and others added 6 commits May 4, 2026 16:09
Identity providers may return token_type in any case (e.g. "bearer", "BEARER")
per RFC 6749/6750, but some downstream servers and proxies reject anything
other than the canonical "Bearer". Add Token.getCanonicalTokenType() and route
the three Authorization-header construction sites (OAuthHeaderFactory,
AzureCliCredentialsProvider, ServingEndpointsDataPlaneImpl) through it.
Non-Bearer schemes pass through unchanged.

Co-authored-by: Isaac
Canonicalize OAuth Bearer scheme when building Authorization header
@github-actions

github-actions Bot commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

If integration tests don't run automatically, an authorized user can run them manually by following the instructions below:

Trigger:
go/deco-tests-run/sdk-java

Inputs:

  • PR number: 821
  • Commit SHA: 220314bdf8635ca0b1bc4860290463ba05e67ebd

Checks will be approved automatically on success.

@renaudhartert-db renaudhartert-db added this pull request to the merge queue Jun 8, 2026
Merged via the queue into main with commit 0baf3d9 Jun 8, 2026
17 checks passed
@renaudhartert-db renaudhartert-db deleted the canonicalize-oauth-bearer-header branch June 8, 2026 13:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants