Skip to content

Canonicalize OAuth Bearer scheme when building Authorization header#788

Open
mkazia wants to merge 2 commits intodatabricks:mainfrom
mkazia:main
Open

Canonicalize OAuth Bearer scheme when building Authorization header#788
mkazia wants to merge 2 commits intodatabricks:mainfrom
mkazia:main

Conversation

@mkazia
Copy link
Copy Markdown

@mkazia mkazia commented May 4, 2026

Summary

  • 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.

Test plan

  • TokenTest.canonicalTokenTypeNormalizesBearerCasing — covers Bearer / bearer / BEARER / BeArEr all canonicalize to Bearer
  • TokenTest.canonicalTokenTypePreservesNonBearerSchemesCustom and MAC pass through unchanged
  • OAuthHeaderFactoryTest parameterized cases assert Authorization: Bearer <token> regardless of input casing; existing Custom case still passes (regression guard against over-canonicalization)
  • mvn -pl databricks-sdk-java -am clean test -Dtest='TokenTest,OAuthHeaderFactoryTest' — 12 passed

This pull request and its description were written by Isaac.

mkazia and others added 2 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
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 4, 2026

Please ensure that the NEXT_CHANGELOG.md file is updated with any relevant changes.
If this is not necessary for your PR, please include the following in your PR description:
NO_CHANGELOG=true
and rerun the job.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 4, 2026

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: 788
  • Commit SHA: 13f0eb53b13eba51078667fe886f0603b919799b

Checks will be approved automatically on success.

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.

1 participant