Commit 7175953
authored
[Internal] Resolve TokenAudience from token_federation_default_oidc_audiences in host metadata (#759)
## Summary
Resolves `tokenAudience` automatically from the
`token_federation_default_oidc_audiences` field returned by the
`/.well-known/databricks-config` host metadata endpoint, removing the
need for manual audience configuration when using OIDC-based
authentication.
## Why
Today, when using Workload Identity Federation or other OIDC-based
credential providers, the `tokenAudience` must either be explicitly
configured by the user or falls back to `accountId` for account-level
hosts. The host metadata endpoint now returns a
`token_federation_default_oidc_audiences` field containing the
recommended audience values. Without this change, users must manually
configure `tokenAudience` even though the server already advertises the
correct value — adding unnecessary friction to OIDC auth setup.
This PR reads the new field during config initialization so that the SDK
automatically picks up the correct audience from host metadata, with
user-configured values still taking priority.
## What changed
### Interface changes
- **`HostMetadata.getTokenFederationDefaultOidcAudiences()`** — New
getter returning `List<String>` of OIDC audiences from host metadata.
### Behavioral changes
- `tokenAudience` resolution now follows a three-tier priority chain:
1. User-configured `tokenAudience` (highest priority, unchanged)
2. First element of `token_federation_default_oidc_audiences` from host
metadata (**new**)
3. `accountId` for account hosts (fallback, unchanged)
### Internal changes
- `HostMetadata`: Added `token_federation_default_oidc_audiences` field
(`List<String>`) with `@JsonProperty` annotation
- `DatabricksConfig.resolveHostMetadata()`: Added audience resolution
logic before the existing `accountId` fallback
- `NEXT_CHANGELOG.md`: Added internal changelog entry
## How is this tested?
- All integration tests passed (manually triggered)
- Three new unit tests in `DatabricksConfigTest.java`:
- `testResolveHostMetadataSetsTokenAudienceFromOidcAudiences` — verifies
audience is resolved from metadata
-
`testResolveHostMetadataDoesNotOverrideExistingTokenAudienceWithOidcAudiences`
— verifies user-configured audience takes priority
- `testResolveHostMetadataOidcAudiencesPriorityOverAccountIdFallback` —
verifies metadata audience takes priority over accountId fallback1 parent 70ba8a8 commit 7175953
File tree
4 files changed
+161
-1
lines changed- databricks-sdk-java/src
- main/java/com/databricks/sdk/core
- oauth
- test/java/com/databricks/sdk/core
4 files changed
+161
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
| |||
Lines changed: 9 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
884 | 884 | | |
885 | 885 | | |
886 | 886 | | |
887 | | - | |
| 887 | + | |
| 888 | + | |
| 889 | + | |
| 890 | + | |
| 891 | + | |
| 892 | + | |
| 893 | + | |
| 894 | + | |
888 | 895 | | |
| 896 | + | |
889 | 897 | | |
890 | 898 | | |
891 | 899 | | |
| |||
Lines changed: 8 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
| |||
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
26 | 30 | | |
27 | 31 | | |
28 | 32 | | |
| |||
53 | 57 | | |
54 | 58 | | |
55 | 59 | | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
56 | 64 | | |
Lines changed: 143 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
657 | 657 | | |
658 | 658 | | |
659 | 659 | | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
660 | 803 | | |
661 | 804 | | |
662 | 805 | | |
| |||
0 commit comments