Canonicalize OAuth Bearer scheme when building Authorization header#821
Merged
Conversation
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
# Conflicts: # NEXT_CHANGELOG.md
Contributor
|
If integration tests don't run automatically, an authorized user can run them manually by following the instructions below: Trigger: Inputs:
Checks will be approved automatically on success. |
hectorcast-db
approved these changes
Jun 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Identity providers may return
token_typein any case (e.g.bearer,BEARER) per RFC 6749/6750, but some downstream servers and proxies reject anything other than the canonicalBearer. This caused intermittent auth failures depending on the IdP's response casing.Adds
Token.getCanonicalTokenType(), which returnsBearerwhenevertokenTypecase-insensitively matchesbearerand otherwise returns the original value untouched. Routes the threeAuthorizationheader construction sites through the new helper:OAuthHeaderFactory.fromTokenSource,AzureCliCredentialsProvider, andServingEndpointsDataPlaneImpl. 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:
TokenTestandOAuthHeaderFactoryTestcover Bearer casing normalization, non-Bearer pass-through, and the assembledAuthorization: Bearer <token>header; 12 passed locally against current main.