-
Notifications
You must be signed in to change notification settings - Fork 135
Scopes support in auth commands #4327
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
tejaskochar-db
wants to merge
9
commits into
main
Choose a base branch
from
scopes
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
9 commits
Select commit
Hold shift + click to select a range
13ba6b7
add scopes to auth describe
tejaskochar-db 32d7397
add scopes to auth profiles
tejaskochar-db ee2b987
add scopes to auth login command
tejaskochar-db 355231d
add acceptance tests for scopes in auth commands
tejaskochar-db fa8cbd1
Merge branch 'main' into scopes
tejaskochar-db 1a8a970
update auth describe acceptance test
tejaskochar-db 32fa5fc
update describe command
tejaskochar-db 25175c8
Merge branch 'main' into scopes
tejaskochar-db d54ef9e
refactor some tests and clean up some comments
tejaskochar-db 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,17 @@ | ||
|
|
||
| >>> [CLI] auth login --host [DATABRICKS_URL] --profile scoped-profile --scopes jobs,pipelines,clusters | ||
| Profile scoped-profile was successfully saved | ||
|
|
||
| >>> [CLI] auth describe --profile scoped-profile | ||
| Host: [DATABRICKS_URL] | ||
| User: [USERNAME] | ||
| Authenticated with: databricks-cli | ||
| ----- | ||
| Current configuration: | ||
| ✓ host: [DATABRICKS_URL] (from DATABRICKS_HOST environment variable) | ||
| ~ token: ******** (from DATABRICKS_TOKEN environment variable, not used for auth type databricks-cli) | ||
| ✓ profile: scoped-profile (from --profile flag) | ||
| ✓ scopes: clusters,jobs,pipelines (from ./home/.databrickscfg config file) | ||
| ✓ databricks_cli_path: [CLI] | ||
| ✓ auth_type: databricks-cli (from ./home/.databrickscfg config file) | ||
| ✓ rate_limit: [NUMID] (from DATABRICKS_RATE_LIMIT environment variable) |
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,11 @@ | ||
| sethome "./home" | ||
|
|
||
| # Use a fake browser that performs a GET on the authorization URL | ||
| # and follows the redirect back to localhost. | ||
| export BROWSER="browser.py" | ||
|
|
||
| # Login with restricted scopes to populate the OAuth token cache | ||
| trace $CLI auth login --host $DATABRICKS_HOST --profile scoped-profile --scopes "jobs,pipelines,clusters" | ||
|
|
||
| # Now describe should show the scopes from the cached OAuth token | ||
| trace $CLI auth describe --profile scoped-profile |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| ; The profile defined in the DEFAULT section is to be used as a fallback when no profile is explicitly specified. | ||
| [DEFAULT] | ||
|
|
||
| [scoped-test] | ||
| host = [DATABRICKS_URL] | ||
| scopes = jobs,pipelines,clusters | ||
| auth_type = databricks-cli |
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,9 @@ | ||
|
|
||
| >>> [CLI] auth login --host [DATABRICKS_URL] --profile scoped-test --scopes jobs,pipelines,clusters | ||
| Profile scoped-test was successfully saved | ||
|
|
||
| >>> [CLI] auth profiles | ||
| Name Host Client ID Scopes Valid | ||
| scoped-test [DATABRICKS_URL] - clusters,jobs,pipelines - | ||
|
|
||
| Note: Validation is skipped for profiles without the 'all-apis' scope because the validation API may not be accessible with restricted scopes. |
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,11 @@ | ||
| sethome "./home" | ||
|
|
||
| # Use a fake browser that performs a GET on the authorization URL | ||
| # and follows the redirect back to localhost. | ||
| export BROWSER="browser.py" | ||
|
|
||
| trace $CLI auth login --host $DATABRICKS_HOST --profile scoped-test --scopes "jobs,pipelines,clusters" | ||
| trace $CLI auth profiles | ||
|
|
||
| # Track the .databrickscfg file that was created to surface changes. | ||
| mv "./home/.databrickscfg" "./out.databrickscfg" |
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,9 @@ | ||
|
|
||
| >>> [CLI] auth profiles | ||
| Name Host Client ID Scopes Valid | ||
| pat [DATABRICKS_URL] - all-apis YES | ||
| restricted-scopes [DATABRICKS_URL] - jobs,pipelines - | ||
| m2m [DATABRICKS_URL] acbd1232123 files,sql - | ||
| default-scopes [DATABRICKS_URL] - all-apis NO | ||
|
|
||
| Note: Validation is skipped for profiles without the 'all-apis' scope because the validation API may not be accessible with restricted scopes. |
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,28 @@ | ||
| sethome "./home" | ||
|
|
||
| # Create profiles with different scope configurations | ||
| cat > "./home/.databrickscfg" <<EOF | ||
| [DEFAULT] | ||
|
|
||
| [pat] | ||
| host = $DATABRICKS_HOST | ||
| auth_type = pat | ||
| token = dapi1234567890 | ||
|
|
||
| [restricted-scopes] | ||
| host = $DATABRICKS_HOST | ||
| scopes = jobs,pipelines | ||
| auth_type = databricks-cli | ||
|
|
||
| [m2m] | ||
| host = $DATABRICKS_HOST | ||
| scopes = sql,files | ||
| client_id = acbd1232123 | ||
| auth_type = m2m | ||
|
|
||
| [default-scopes] | ||
| host = $DATABRICKS_HOST | ||
| auth_type = databricks-cli | ||
| EOF | ||
|
|
||
| trace $CLI auth profiles |
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
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.
Uh oh!
There was an error while loading. Please reload this page.
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.
In case of insufficient scopes, the server responds with a 403 and
Provided OAuth token does not have required scopes: ...message. I could instead match on the error message and determine auth to be valid instead of adding a note saying the error may just be due to insufficient scopes.This is, of course, brittle but allows for more accurate validation.
What is the reason for having this validation in the first place?