You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Feature] Resolve TokenAudience from default_oidc_audience in host metadata (#1597)
## Summary
Adds `DefaultOIDCAudience` to the `HostMetadata` struct so the SDK can
parse the new `default_oidc_audience` field from the
`/.well-known/databricks-config` discovery endpoint and use it to
populate `TokenAudience` during config resolution.
## Why
Today, `TokenAudience` for account hosts is inferred by a heuristic: if
the host metadata has no `workspace_id` and has an `account_id`, the SDK
sets
`TokenAudience` to the account ID. For workspace hosts, no audience is
set at all — credential strategies must know the right value
independently.
The server-side `/.well-known/databricks-config` endpoint is being
updated to return a `default_oidc_audience` field that provides the
correct OIDC audience
directly:
- **Workspace hosts**: `https://<workspace_host>/oidc/v1/token`
- **Account/unified hosts**: the resolved account ID
Using this authoritative value from the server removes the need for
host-pattern guessing and ensures correctness for vanity domains,
unified hosts, and future
host types.
## What changed
### Interface changes
- **`HostMetadata.DefaultOIDCAudience string`** — New field
(`json:"default_oidc_audience"`) that holds the default OIDC audience
from the discovery endpoint.
### Behavioral changes
- During `resolveHostMetadata`, if `TokenAudience` is empty and
`meta.DefaultOIDCAudience` is non-empty, `TokenAudience` is set from it.
This takes priority over
the existing account-ID-based fallback.
- User-set `TokenAudience` is never overwritten.
- Servers that do not return the field fall back to the existing
behavior (no breaking change).
### Internal changes
None.
## How is this tested?
Unit tests covering all resolution paths:
- `TestGetHostMetadata_WithDefaultOIDCAudience` — JSON parsing for
workspace audience, account audience, and missing field
- `TestApplyHostMetadata_SetsTokenAudienceFromDefaultOIDCAudience` —
audience resolved from well-known for workspace host
-
`TestApplyHostMetadata_DefaultOIDCAudienceTakesPriorityOverAccountIDFallback`
— new field wins over account-ID fallback
- `TestApplyHostMetadata_DefaultOIDCAudienceDoesNotOverrideExisting` —
user-set `TokenAudience` preserved
- `TestApplyHostMetadata_FallsBackToAccountIDWhenNoDefaultOIDCAudience`
— backward compat with old servers
Copy file name to clipboardExpand all lines: NEXT_CHANGELOG.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,6 +10,7 @@
10
10
11
11
* Added `HostMetadataResolver` hook to allow callers to customize host metadata resolution, e.g. with caching ([#1572](https://github.com/databricks/databricks-sdk-go/pull/1572)).
12
12
* Added `NewLimitIterator` to `listing` package for lazy iteration with a cap on output items ([#1555](https://github.com/databricks/databricks-sdk-go/pull/1555)).
13
+
* Resolve `TokenAudience` from `default_oidc_audience` in host metadata discovery endpoint.
0 commit comments