-
Notifications
You must be signed in to change notification settings - Fork 191
Make an explicitly selected profile take precedence over auth environment variables #5702
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
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
403af4c
Make --profile take precedence over auth environment variables
radakam b244522
Cover bundle profile and auth_type/discovery_url env precedence
radakam 68a07f7
Let env fill auth fields a selected profile leaves empty
radakam 72e217e
Refine profile precedence handling and extend coverage
radakam 95aacc0
Trim verbose comments to keep only necessary rationale
radakam a8e961c
Guard default_profile against env auth in databricks api
radakam 8ef7b6a
Skip auth-steering env vars gap-filling a selected profile
radakam 29d2b24
Gap-fill the host from env for a host-less selected profile
radakam 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
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
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,22 @@ | ||
|
|
||
| === api without --profile uses env auth, ignoring default_profile (#5616) | ||
|
|
||
| >>> [CLI] api get /api/2.0/clusters/list | ||
| {} | ||
|
|
||
| >>> print_requests.py --get //api/2.0/clusters/list | ||
| { | ||
| "headers": { | ||
| "Authorization": [ | ||
| "Bearer [DATABRICKS_TOKEN]" | ||
| ], | ||
| "User-Agent": [ | ||
| "cli/[DEV_VERSION] databricks-sdk-go/[SDK_VERSION] go/[GO_VERSION] os/[OS] cmd/api_get cmd-exec-id/[UUID] interactive/none auth/pat" | ||
| ], | ||
| "X-Databricks-Workspace-Id": [ | ||
| "[NUMID]" | ||
| ] | ||
| }, | ||
| "method": "GET", | ||
| "path": "/api/2.0/clusters/list" | ||
| } |
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,19 @@ | ||
| sethome "./home" | ||
|
|
||
| # A default profile with conflicting (basic) auth on a different host. The env | ||
| # below still points a PAT at the test server. Without the #5616 guard, the | ||
| # default profile would be pinned and merged with the env PAT, failing with | ||
| # "more than one authorization method configured". | ||
| cat > "./home/.databrickscfg" <<EOF | ||
| [__settings__] | ||
| default_profile = other | ||
|
|
||
| [other] | ||
| host = https://other.cloud.databricks.test | ||
| username = user | ||
| password = pass | ||
| EOF | ||
|
|
||
| title "api without --profile uses env auth, ignoring default_profile (#5616)\n" | ||
| MSYS_NO_PATHCONV=1 trace $CLI api get /api/2.0/clusters/list | ||
| trace print_requests.py --get //api/2.0/clusters/list |
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,3 @@ | ||
| Ignore = [ | ||
| "home", | ||
| ] |
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,44 @@ | ||
|
|
||
| === api --profile overrides auth env vars (#5096) | ||
|
|
||
| >>> [CLI] api get /api/2.0/clusters/list --profile my-workspace | ||
| {} | ||
|
|
||
| >>> print_requests.py --get //api/2.0/clusters/list | ||
| { | ||
| "headers": { | ||
| "Authorization": [ | ||
| "Bearer [DATABRICKS_TOKEN]" | ||
| ], | ||
| "User-Agent": [ | ||
| "cli/[DEV_VERSION] databricks-sdk-go/[SDK_VERSION] go/[GO_VERSION] os/[OS] cmd/api_get cmd-exec-id/[UUID] interactive/none auth/pat" | ||
| ], | ||
| "X-Databricks-Workspace-Id": [ | ||
| "[NUMID]" | ||
| ] | ||
| }, | ||
| "method": "GET", | ||
| "path": "/api/2.0/clusters/list" | ||
| } | ||
|
|
||
| === api host-only --profile fills the token from the environment (#5096) | ||
|
|
||
| >>> [CLI] api get /api/2.0/clusters/list --profile host-only | ||
| {} | ||
|
|
||
| >>> print_requests.py --get //api/2.0/clusters/list | ||
| { | ||
| "headers": { | ||
| "Authorization": [ | ||
| "Bearer [DATABRICKS_TOKEN]" | ||
| ], | ||
| "User-Agent": [ | ||
| "cli/[DEV_VERSION] databricks-sdk-go/[SDK_VERSION] go/[GO_VERSION] os/[OS] cmd/api_get cmd-exec-id/[UUID] interactive/none auth/pat" | ||
| ], | ||
| "X-Databricks-Workspace-Id": [ | ||
| "[NUMID]" | ||
| ] | ||
| }, | ||
| "method": "GET", | ||
| "path": "/api/2.0/clusters/list" | ||
| } |
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,29 @@ | ||
| sethome "./home" | ||
|
|
||
| # One profile with full credentials, one host-only; both point at the test | ||
| # server while the auth env vars below point elsewhere. | ||
| cat > "./home/.databrickscfg" <<EOF | ||
| [my-workspace] | ||
| host = $DATABRICKS_HOST | ||
| token = $DATABRICKS_TOKEN | ||
|
|
||
| [host-only] | ||
| host = $DATABRICKS_HOST | ||
| EOF | ||
|
|
||
| # direnv-style auth env vars for a different workspace; before #5096 these | ||
| # shadowed the profile selected with --profile. | ||
| real_token=$DATABRICKS_TOKEN | ||
| export DATABRICKS_HOST=https://dev.cloud.databricks.test | ||
| export DATABRICKS_TOKEN=dev-token | ||
|
|
||
| title "api --profile overrides auth env vars (#5096)\n" | ||
| MSYS_NO_PATHCONV=1 trace $CLI api get /api/2.0/clusters/list --profile my-workspace | ||
| trace print_requests.py --get //api/2.0/clusters/list | ||
|
|
||
| # Host-only profile: the profile wins for the host, but env fills the token it | ||
| # omits (#5096). | ||
| export DATABRICKS_TOKEN=$real_token | ||
| title "api host-only --profile fills the token from the environment (#5096)\n" | ||
| MSYS_NO_PATHCONV=1 trace $CLI api get /api/2.0/clusters/list --profile host-only | ||
| trace print_requests.py --get //api/2.0/clusters/list |
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,3 @@ | ||
| Ignore = [ | ||
| "home", | ||
| ] |
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
3 changes: 3 additions & 0 deletions
3
acceptance/cmd/auth/describe/profile-overrides-env/out.test.toml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
36 changes: 36 additions & 0 deletions
36
acceptance/cmd/auth/describe/profile-overrides-env/output.txt
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,36 @@ | ||
|
|
||
| === Describe with --profile overrides auth env vars (#5096) | ||
|
|
||
| >>> [CLI] auth describe --profile my-workspace | ||
| Host: [DATABRICKS_URL] | ||
| User: [USERNAME] | ||
| Authenticated with: pat | ||
| ----- | ||
| Current configuration: | ||
| ✓ host: [DATABRICKS_URL] (from [TEST_TMP_DIR]/home/.databrickscfg config file) | ||
| ✓ workspace_id: [NUMID] | ||
| ✓ token: ******** (from [TEST_TMP_DIR]/home/.databrickscfg config file) | ||
| ✓ profile: my-workspace (from --profile flag) | ||
| ✓ databricks_cli_path: [CLI] | ||
| ✓ auth_type: pat | ||
| ✓ rate_limit: [NUMID] (from DATABRICKS_RATE_LIMIT environment variable) | ||
| ✓ cloud: AWS | ||
| ✓ discovery_url: [DATABRICKS_URL]/oidc/.well-known/oauth-authorization-server | ||
|
|
||
| === Describe with a host-only --profile fills the token from the environment (#5096) | ||
|
|
||
| >>> [CLI] auth describe --profile host-only | ||
| Host: [DATABRICKS_URL] | ||
| User: [USERNAME] | ||
| Authenticated with: pat | ||
| ----- | ||
| Current configuration: | ||
| ✓ host: [DATABRICKS_URL] (from [TEST_TMP_DIR]/home/.databrickscfg config file) | ||
| ✓ workspace_id: [NUMID] | ||
| ✓ token: ******** (from DATABRICKS_TOKEN environment variable) | ||
| ✓ profile: host-only (from --profile flag) | ||
| ✓ databricks_cli_path: [CLI] | ||
| ✓ auth_type: pat | ||
| ✓ rate_limit: [NUMID] (from DATABRICKS_RATE_LIMIT environment variable) | ||
| ✓ cloud: AWS | ||
| ✓ discovery_url: [DATABRICKS_URL]/oidc/.well-known/oauth-authorization-server |
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,26 @@ | ||
| sethome "./home" | ||
|
|
||
| # A profile carries full credentials; a second profile carries only a host. | ||
| cat > "./home/.databrickscfg" <<EOF | ||
| [my-workspace] | ||
| host = $DATABRICKS_HOST | ||
| token = $DATABRICKS_TOKEN | ||
|
|
||
| [host-only] | ||
| host = $DATABRICKS_HOST | ||
| EOF | ||
|
|
||
| # direnv-style auth env vars for a different workspace; before #5096 these | ||
| # shadowed the profile selected with --profile. | ||
| real_token=$DATABRICKS_TOKEN | ||
| export DATABRICKS_HOST=https://dev.cloud.databricks.test | ||
| export DATABRICKS_TOKEN=dev-token | ||
|
|
||
| title "Describe with --profile overrides auth env vars (#5096)\n" | ||
| trace $CLI auth describe --profile my-workspace | ||
|
|
||
| # Host-only profile: the profile wins for the host, but env fills the token it | ||
| # omits (#5096). | ||
| export DATABRICKS_TOKEN=$real_token | ||
| title "Describe with a host-only --profile fills the token from the environment (#5096)\n" | ||
| trace $CLI auth describe --profile host-only |
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,3 @@ | ||
| Ignore = [ | ||
| "home" | ||
| ] |
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
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.
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.
Uh oh!
There was an error while loading. Please reload this page.