Skip to content

Support custom scopes and redirectUrl for U2M OAuth flow#190

Merged
mgyucht merged 5 commits intodatabricks:mainfrom
gopalldb:redirecturl
Nov 24, 2023
Merged

Support custom scopes and redirectUrl for U2M OAuth flow#190
mgyucht merged 5 commits intodatabricks:mainfrom
gopalldb:redirecturl

Conversation

@gopalldb
Copy link
Copy Markdown
Contributor

Changes

Added following utility methods to DatabricksConfig

a. setRedirectUrl: This will be passed to OAuthClient and will be used in U2M OAuth flow if client wants to provide a custom redirect Url as per OAuth configuration of their application.
b. setScopes: Clients can set custom scopes for U2M OAuth flow. If offline_access is not present, it will be added to the scopes for refresh token support.

Tests

Tested manually using JDBC driver as a client. Also, added test case for custom values of redirectUrl and scopes.

@gopalldb gopalldb requested a review from mgyucht November 17, 2023 08:50
@gopalldb gopalldb self-assigned this Nov 17, 2023
Copy link
Copy Markdown
Contributor

@mgyucht mgyucht left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall seems good, but I am not sure why we would want all apps to request offline_access scope, it seems like it should be opt-in like with the /token API itself.

sensitive = true)
private String clientSecret;

@ConfigAttribute(value = "scopes", env = "DATABRICKS_SCOPES", auth = "oauth", sensitive = true)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Scopes are not sensitive, are they?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Usually they are case sensitive: e.g. AzureAD/microsoft-authentication-library-for-objc#395. Not sure about Databricks handling.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sensitive here means that it shouldn't be put into logs, not that it is case-sensitive.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My bad. I misunderstood. :( Updated

value = "redirect_url",
env = "DATABRICKS_REDIRECT_URL",
auth = "oauth",
sensitive = true)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto, probably not sensitive.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

Comment on lines +123 to +125
} else if (!scopes.contains("offline_access")) {
scopes = new ArrayList<>(scopes);
scopes.add("offline_access");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why should we add this always?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed. Added to support refresh tokens, but clients may intentionally avoid this for short lived token use-case.

@gopalldb gopalldb requested a review from mgyucht November 23, 2023 17:15
@gopalldb
Copy link
Copy Markdown
Contributor Author

Overall seems good, but I am not sure why we would want all apps to request offline_access scope, it seems like it should be opt-in like with the /token API itself.

Removed that. Now it is opt-in for clients.

@mgyucht mgyucht added this pull request to the merge queue Nov 24, 2023
Merged via the queue into databricks:main with commit 1c0f929 Nov 24, 2023
mgyucht added a commit that referenced this pull request Nov 29, 2023
Bug fixes:

* Fix databricks CLI authentication on Windows ([#192](#192)).
* Fix SCIM pagination ([#193](#193)).

Other changes:

* Add more detailed error message on default credentials not found error ([#180](#180)).
* Support custom scopes and redirectUrl for U2M OAuth flow ([#190](#190)).

API Changes:

 * Removed `enableOptimization()` method for `workspaceClient.metastores()` service.
 * Added `pipelineId` field for `com.databricks.sdk.service.catalog.TableInfo`.
 * Added `enablePredictiveOptimization` field for `com.databricks.sdk.service.catalog.UpdateCatalog` and `com.databricks.sdk.service.catalog.UpdateSchema`.
 * Removed `com.databricks.sdk.service.catalog.UpdatePredictiveOptimization` and `com.databricks.sdk.service.catalog.UpdatePredictiveOptimizationResponse` class.
 * Added `description` field for `com.databricks.sdk.service.jobs.CreateJob` and `com.databricks.sdk.service.jobs.JobSettings`.
 * Added `listNetworkConnectivityConfigurations()` and `listPrivateEndpointRules()` methods for `accountClient.networkConnectivity()` service.
 * Added `com.databricks.sdk.service.settings.ListNccAzurePrivateEndpointRulesResponse`, `com.databricks.sdk.service.settings.ListNetworkConnectivityConfigurationsRequest`, `com.databricks.sdk.service.settings.ListNetworkConnectivityConfigurationsResponse`, and `com.databricks.sdk.service.settings.ListPrivateEndpointRulesRequest` classes.
 * Added `stringSharedAs` field for `com.databricks.sdk.service.sharing.SharedDataObject`.

OpenAPI SHA: 22f09783eb8a84d52026f856be3b2068f9498db3, Date: 2023-11-23

Dependency updates:

 * Bump API spec: 23 Nov 2023 ([#191](#191)).
@mgyucht mgyucht mentioned this pull request Nov 29, 2023
github-merge-queue bot pushed a commit that referenced this pull request Nov 29, 2023
Bug fixes:

* Fix databricks CLI authentication on Windows
([#192](#192)).
* Fix SCIM pagination
([#193](#193)).

Other changes:

* Add more detailed error message on default credentials not found error
([#180](#180)).
* Support custom scopes and redirectUrl for U2M OAuth flow
([#190](#190)).

API Changes:

* Removed `enableOptimization()` method for
`workspaceClient.metastores()` service.
* Added `pipelineId` field for
`com.databricks.sdk.service.catalog.TableInfo`.
* Added `enablePredictiveOptimization` field for
`com.databricks.sdk.service.catalog.UpdateCatalog` and
`com.databricks.sdk.service.catalog.UpdateSchema`.
* Removed
`com.databricks.sdk.service.catalog.UpdatePredictiveOptimization` and
`com.databricks.sdk.service.catalog.UpdatePredictiveOptimizationResponse`
class.
* Added `description` field for
`com.databricks.sdk.service.jobs.CreateJob` and
`com.databricks.sdk.service.jobs.JobSettings`.
* Added `listNetworkConnectivityConfigurations()` and
`listPrivateEndpointRules()` methods for
`accountClient.networkConnectivity()` service.
* Added
`com.databricks.sdk.service.settings.ListNccAzurePrivateEndpointRulesResponse`,
`com.databricks.sdk.service.settings.ListNetworkConnectivityConfigurationsRequest`,
`com.databricks.sdk.service.settings.ListNetworkConnectivityConfigurationsResponse`,
and
`com.databricks.sdk.service.settings.ListPrivateEndpointRulesRequest`
classes.
* Added `stringSharedAs` field for
`com.databricks.sdk.service.sharing.SharedDataObject`.

OpenAPI SHA: 22f09783eb8a84d52026f856be3b2068f9498db3, Date: 2023-11-23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants