Skip to content

Canonicalize OAuth Bearer scheme when building Authorization header#788

Open
mkazia wants to merge 5 commits into
databricks:mainfrom
mkazia:main
Open

Canonicalize OAuth Bearer scheme when building Authorization header#788
mkazia wants to merge 5 commits into
databricks: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
@chrisst chrisst requested a review from renaudhartert-db May 27, 2026 10:01
@renaudhartert-db
Copy link
Copy Markdown
Contributor

Looks good overall, with a small comment. Could you also make sure the NEXT_CHANGELOG.md file is updated with your change?

@mkazia mkazia temporarily deployed to test-trigger-is May 30, 2026 08:51 — with GitHub Actions Inactive
@github-actions
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: 788
  • Commit SHA: 212ef2ffa9985a3bad08c4dc006790752f72b2f7

Checks will be approved automatically on success.

@mkazia
Copy link
Copy Markdown
Author

mkazia commented May 30, 2026

Looks good overall, with a small comment. Could you also make sure the NEXT_CHANGELOG.md file is updated with your change?

done

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.

2 participants