Canonicalize OAuth Bearer scheme when building Authorization header#788
Open
mkazia wants to merge 2 commits intodatabricks:mainfrom
Open
Canonicalize OAuth Bearer scheme when building Authorization header#788mkazia wants to merge 2 commits intodatabricks:mainfrom
mkazia wants to merge 2 commits intodatabricks:mainfrom
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
Contributor
|
Please ensure that the NEXT_CHANGELOG.md file is updated with any relevant changes. |
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. |
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.
Summary
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.Token.getCanonicalTokenType(), which returns"Bearer"whenevertokenTypecase-insensitively matches"bearer"and otherwise returns the original value untouched.Authorizationheader construction sites through the new helper:OAuthHeaderFactory.fromTokenSource,AzureCliCredentialsProvider, andServingEndpointsDataPlaneImpl. Non-Bearer schemes (e.g.MAC, custom) are unchanged.Test plan
TokenTest.canonicalTokenTypeNormalizesBearerCasing— coversBearer/bearer/BEARER/BeArErall canonicalize toBearerTokenTest.canonicalTokenTypePreservesNonBearerSchemes—CustomandMACpass through unchangedOAuthHeaderFactoryTestparameterized cases assertAuthorization: Bearer <token>regardless of input casing; existingCustomcase still passes (regression guard against over-canonicalization)mvn -pl databricks-sdk-java -am clean test -Dtest='TokenTest,OAuthHeaderFactoryTest'— 12 passedThis pull request and its description were written by Isaac.