-
Notifications
You must be signed in to change notification settings - Fork 156
Fix auth profiles misclassifying SPOG hosts as workspace configs
#4929
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
mihaimitrea-db
wants to merge
6
commits into
main
Choose a base branch
from
mihaimitrea-db/fix-profiles-spog-classification
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
32e780a
Fix auth profiles misclassifying SPOG hosts as workspace configs
mihaimitrea-db 7b8d122
Add acceptance test for SPOG account profile validation
mihaimitrea-db 456280f
Use tagged switch to fix staticcheck QF1002 lint errors
mihaimitrea-db a7198ac
Clean up test: remove unused field, fix misleading comment
mihaimitrea-db c680516
Address PR review comments
mihaimitrea-db 05c4f39
Merge branch 'main' into mihaimitrea-db/fix-profiles-spog-classification
simonfaltum File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
|
|
||
| === SPOG account profile should be valid | ||
| >>> [CLI] auth profiles --output json | ||
| { | ||
| "profiles": [ | ||
| { | ||
| "name":"spog-account", | ||
| "host":"[DATABRICKS_URL]", | ||
| "account_id":"spog-acct-123", | ||
| "workspace_id":"none", | ||
| "cloud":"aws", | ||
| "auth_type":"pat", | ||
| "valid":true | ||
| } | ||
| ] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| sethome "./home" | ||
|
|
||
| # Create a SPOG account profile: non-accounts.* host with account_id, no workspace_id. | ||
| # Before the fix, this was misclassified as WorkspaceConfig and validated with | ||
| # CurrentUser.Me, which fails on account-scoped SPOG hosts. | ||
| cat > "./home/.databrickscfg" <<EOF | ||
| [spog-account] | ||
| host = ${DATABRICKS_HOST} | ||
| account_id = spog-acct-123 | ||
| workspace_id = none | ||
| token = test-token | ||
| EOF | ||
|
|
||
| title "SPOG account profile should be valid" | ||
| trace $CLI auth profiles --output json |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| Ignore = [ | ||
| "home" | ||
| ] | ||
|
|
||
| # Override .well-known to return account-scoped OIDC, simulating a SPOG host. | ||
| # The oidc_endpoint contains /oidc/accounts/ which signals account-scoped OIDC. | ||
| [[Server]] | ||
| Pattern = "GET /.well-known/databricks-config" | ||
| Response.Body = ''' | ||
| { | ||
| "account_id": "spog-acct-123", | ||
| "oidc_endpoint": "localhost/oidc/accounts/spog-acct-123" | ||
| } | ||
| ''' | ||
|
|
||
| # Provide a handler for the account workspaces list endpoint used by | ||
| # auth profiles validation for account-type configs. | ||
| [[Server]] | ||
| Pattern = "GET /api/2.0/accounts/spog-acct-123/workspaces" | ||
| Response.Body = '[]' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion (follow-up): The SPOG detection heuristic (DiscoveryURL contains
/oidc/accounts/+ IsUnifiedHost fallback) is now duplicated between here andlibs/auth/arguments.go:69-82. The cross-referencing comments help, but if the routing logic changes in one place the other can drift.Consider extracting a shared helper in
libs/auth/in a follow-up, e.g.:Not blocking for this PR since the logic is simple and well-documented.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would be good to have. Bonus points that it moves some of the logic form the SDK to the CLI.