Commit 0baf3d9
Canonicalize OAuth Bearer scheme when building Authorization header (#821)
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.
---------
Co-authored-by: Mubashir Kazia <mkazia@gmail.com>
Co-authored-by: mkazia <3633226+mkazia@users.noreply.github.com>1 parent 1b7fe25 commit 0baf3d9
7 files changed
Lines changed: 51 additions & 4 deletions
File tree
- databricks-sdk-java/src
- main/java/com/databricks/sdk
- core
- oauth
- service/serving
- test/java/com/databricks/sdk/core/oauth
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
| |||
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
| 19 | + | |
Lines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
99 | 99 | | |
100 | 100 | | |
101 | 101 | | |
102 | | - | |
| 102 | + | |
| 103 | + | |
103 | 104 | | |
104 | 105 | | |
105 | 106 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
54 | | - | |
| 54 | + | |
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
| |||
Lines changed: 16 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
54 | 70 | | |
55 | 71 | | |
56 | 72 | | |
| |||
Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 13 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
39 | | - | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
40 | 52 | | |
41 | 53 | | |
42 | 54 | | |
| |||
Lines changed: 16 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
32 | 48 | | |
0 commit comments