Skip to content

Commit b8f7994

Browse files
committed
[PP-2216] Update API doc for OAuthU2M Support
1 parent e25ed2f commit b8f7994

File tree

7 files changed

+32
-8
lines changed

7 files changed

+32
-8
lines changed

ApiSpecifications.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,8 @@ POST <partners/databricks/v1/connect>: [example, can be customized]
160160
"is_sql_warehouse": true|false, [optional: set if cluster_id is set. Determines whether cluster_id refers to Interactive Cluster or SQL Warehouse]
161161
"data_source_connector": "Oracle", [optional, unused and reserved for future use: for data connector tools, the name of the data source that the user should be referred to in their tool]
162162
"service_principal_id": "a2a25a05-3d59-4515-a73b-b8bc5ab79e31", [optional, the UUID (username) of the service principal identity]
163-
"service_principal_oauth_secret": "dose..." [optional, the OAuth secret of the service principal identity, it will be passed only when partner config includes OAuth M2M auth option]
163+
"service_principal_oauth_secret": "dose...", [optional, the OAuth secret of the service principal identity, it will be passed only when the partner config includes OAuth M2M auth option]
164+
"oauth_u2m_app_id": "782b7906-20c4-4c12-8850-b26b77d125f5" [optional, the client ID of Databricks OAuth U2M app connection created by Partner Connect. It will be passed only when the partner config includes OAuth U2M auth option]
164165
}
165166
```
166167

@@ -174,7 +175,8 @@ Status Code: 200
174175
"connection_id": "7f2e4c43-9714-47cf-9011-d8148eaa27a2", [example, optional, see below]
175176
"user_status": "new", [example]
176177
"account_status": "existing", [example]
177-
"configured_resources": true|false
178+
"configured_resources": true|false,
179+
"oauth_redirect_uri": "http://www.partner.com/oauth/callback [example, optional, see below]
178180
}
179181
```
180182
Return values:
@@ -190,6 +192,7 @@ Return values:
190192
6. **configured\_resources** - a boolean that represents whether the partner configured/persisted the Databricks resources on this Connect API request.
191193
1. If **is\_connection\_established** is true, **configured\_resources** must be set, but will be ignored.
192194
2. If **is\_connection\_established** is false and **configured\_resources** is false, Databricks will delete the resources it provisioned.
195+
7. **oauth\_redirect\_uri** - the partner application's URL that handles Databricks OAuth redirect request in the OAuth U2M flow (Authorization code flow). It should be set only when the partner is configured with OAuth U2M as the auth option ([ParterConfig](./api-doc/Models/PartnerConfig.md) `auth_options` contains `AUTH_OAUTH_U2M`) and does not have a pre-registered Databricks published OAuth app connection ([ParterConfig](./api-doc/Models/PartnerConfig.md) `is_published_app` is `false` or `null`).
193196

194197
**Failure Responses:**
195198

OnboardingDoc.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ The following phrases will help you understand the Databricks product and this d
3232
- **Personal Access Token (PAT):** A token that a partner product can use to authenticate with Databricks
3333
- **Service Principal:** An account that a partner product can use when calling Databricks APIs. Service Principals have access controls associated with them.
3434
- **OAuth M2M** It uses service principals to authenticate Databricks. It is also known as 2-legged OAuth and OAuth Client Credentials Flow. Partner product can use service principal UUD (client_id) and OAuth secret (client_secret) to authenticate with Databricks.
35+
- **OAuth U2M** It allows users to access Databricks account and workspace resources via the partner application on behalf of a user. It is also known as 3-legged OAuth and OAuth Authorization Code Flow.
36+
- **Published OAuth application** The application that is pre-registered by Databricks and is available in all the Databricks accounts. For the app to be eligible for published application, it must meet the following requirements:
37+
- The OAuth redirect URLs of the app should be fixed instead of account/customer/tenant specific
38+
- The app cannot be confidential app (no client secret) and has to support [PKCE](https://oauth.net/2/pkce/)
3539
- **Service Principal OAuth Secret**: The service principal's secret that a partner product use it along with service principal UUID to authenticate with Databricks.
3640

3741

api-doc/Models/ConnectRequest.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
| **service\_principal\_id** | **String** | The UUID (username) of the service principal identity that a partner product can use to call Databricks APIs. Note the format is different from the databricks_user_id field in user_info. If empty, no service principal was created | [optional] [default to null] |
2727
| **service\_principal\_oauth\_secret** | **String** | The OAuth secret of the service principal identity that a partner product can use to call Databricks APIs (see [OAuth M2M](https://docs.databricks.com/en/dev-tools/auth/oauth-m2m.html)). It will be set only when the `auth_options` in the [PartnerConfig](PartnerConfig.md) contains the value `AUTH_OAUTH_M2M`. | [optional] [default to null] |
2828
| **connection\_scope** | **String** | The scope of users that can use this connection. Workspace means all users in the same workspace. User means only the user creating it. | [optional] [default to null] |
29+
| **oauth\_u2m\_app\_id** | **String** | The client ID of OAuth U2M app connection (created by Partner Connect) that a partner product can use to initiate Databricks OAuth U2M flow. It will be set only when the `auth_options` in the [PartnerConfig](PartnerConfig.md) contains the value `AUTH_OAUTH_U2M`. | [optional] [default to null] |
2930

3031
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
3132

api-doc/Models/PartnerConfig.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@
2323
| **require\_manual\_signup** | **Boolean** | True if the partner requires a manual signup after connect api is called. When set to true, connect api call with is_connection_established (sign in) is expected to return 404 account_not_found or connection_not_found until the user completes the manual signup step. | [optional] [default to null] |
2424
| **trial\_type** | **String** | Enum describing the type of trials the partner support. Partners can chose to support trial account expiration at the individual user or account level. If trial level is user, expiring one user connection should not expire another user in the same account. | [optional] [default to null] |
2525
| **supports\_demo** | **Boolean** | True if partner supports the demo flag in the connect api call. | [optional] [default to null] |
26-
| **auth\_options** | **List** | The available authentication methods that a partner can use to authenticate with Databricks. If it is not specified, `AUTH_PAT` will be used. The allowed options include <ul><li><b>AUTH_PAT</b></li><li><b>AUTH_OAUTH_M2M</b></li></ul>| [optional] [default to null] |
26+
| **auth\_options** | **List** | The available authentication methods that a partner can use to authenticate with Databricks. If it is not specified, `AUTH_PAT` will be used. The allowed options include <ul><li><b>AUTH_PAT</b></li><li><b>AUTH_OAUTH_M2M</b></li><li><b>AUTH_OAUTH_U2M</b></li></ul>| [optional] [default to null] |
2727
| **test\_workspace\_detail** | [**PartnerConfig_test_workspace_detail**](PartnerConfig_test_workspace_detail.md) | | [optional] [default to null] |
28+
| **is_published_app** | **Boolean** | True if the partner app is registered as Databricks published OAuth app | [optional] [default to null] |
2829

2930
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
3031

openapi/partner-connect-2.0.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,12 @@ components:
488488
The secret of the service principal identity that a partner product can use to call Databricks APIs.
489489
It will be set only when the auth_options in PartnerConfig contains the value AUTH_OAUTH_M2M.
490490
example: "secret"
491+
oauth_u2m_app_id:
492+
type: string
493+
description: |
494+
The client ID of OAuth U2M app connection (created by Partner Connect) that a partner product can use to initiate Databricks OAuth U2M flow.
495+
It will be set only when the auth_options in the PartnerConfig contains the value AUTH_OAUTH_U2M.
496+
example: "22c42f74-1dec-43d2-b649-3643f2e1e927"
491497
connection_scope:
492498
type: string
493499
description: The scope of users that can use this connection. Workspace means all users in the same workspace. User means only the user creating it.
@@ -543,6 +549,12 @@ components:
543549
type: boolean
544550
description: A boolean that represents whether the partner configured/persisted the Databricks resources on this Connect API request. If the value is false and is_connection_established is false, Databricks will clean up the resources it provisioned
545551
example: true
552+
oauth_redirect_uri:
553+
type: string
554+
description: |
555+
The partner application's URL that handles Databricks OAuth redirect request in the OAuth U2M flow (Authorization code flow).
556+
It should be set only when the partner is configured with OAuth U2M as auth option and does not have a pre-registered Databricks published OAuth app connection.
557+
example: https://www.partner.com/oauth/callback
546558
ErrorResponse:
547559
type: object
548560
required:

src/main/scala/com/databricks/partnerconnect/example/formatters/JsonFormatters.scala

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ object JsonFormatters extends DefaultJsonProtocol {
6767
new EnumJsonFormatter(TrialType)
6868
}
6969

70-
implicit val connectResponse: RootJsonFormat[Connection] = jsonFormat6(
70+
implicit val connectResponse: RootJsonFormat[Connection] = jsonFormat7(
7171
Connection
7272
)
7373
implicit val auth: RootJsonFormat[Auth] = jsonFormat3(Auth)
@@ -152,7 +152,8 @@ object JsonFormatters extends DefaultJsonProtocol {
152152
),
153153
"connection_scope" -> request.connection_scope
154154
.map(_.toJson)
155-
.getOrElse(JsNull)
155+
.getOrElse(JsNull),
156+
"oauth_u2m_app_id" -> OptionJsString(request.oauth_u2m_app_id)
156157
)
157158

158159
implicit val connectRequest: RootJsonFormat[ConnectRequest] =
@@ -193,7 +194,8 @@ object JsonFormatters extends DefaultJsonProtocol {
193194
service_principal_id = getOptionString(fields, "service_principal_id"),
194195
service_principal_oauth_secret =
195196
getOptionString(fields, "service_principal_oauth_secret"),
196-
connection_scope = scoptOpt
197+
connection_scope = scoptOpt,
198+
oauth_u2m_app_id = getOptionString(fields, "oauth_u2m_app_id")
197199
)
198200
}
199201
}

src/test/scala/com/databricks/partnerconnect/client/tests/JsonFormattersTest.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,12 @@ class JsonFormattersTest extends PartnerTestBase {
4242
service_principal_id = Some("test-service-principal-id"),
4343
service_principal_oauth_secret =
4444
Some("test-service-principal-oauth-secret"),
45-
connection_scope = Some(ConnectRequestEnums.ConnectionScope.Workspace)
45+
connection_scope = Some(ConnectRequestEnums.ConnectionScope.Workspace),
46+
oauth_u2m_app_id = Some("test-oauth-u2m-app-id")
4647
)
4748

4849
val connectionRequestJson =
49-
"""{"catalog_name":"test-catalog-name","cloud_provider":"aws","cloud_provider_region":"test-cloud-provider-region","cluster_id":"test-cluster-id","connection_id":"test-connection-id","connection_scope":"workspace","data_source_connector":"test-data-source-connector","database_name":"test-database-name","databricks_jdbc_url":"jdbc://test-databricks-jdbc-url","demo":true,"destination_location":"test-destination-location","hostname":"test-hostname","http_path":"test-http-path","is_free_trial":true,"is_sql_endpoint":true,"is_sql_warehouse":true,"jdbc_url":"jdbc://test-jdcc-url","port":443,"service_principal_id":"test-service-principal-id","service_principal_oauth_secret":"test-service-principal-oauth-secret","user_info":{"databricks_organization_id":4645065419173783088,"databricks_user_id":5845867166711048519,"email":"[email protected]","first_name":"test-first-name","is_connection_established":false,"last_name":"test-last-name"},"workspace_id":1,"workspace_url":"https://test-workspace-url"}"""
50+
"""{"catalog_name":"test-catalog-name","cloud_provider":"aws","cloud_provider_region":"test-cloud-provider-region","cluster_id":"test-cluster-id","connection_id":"test-connection-id","connection_scope":"workspace","data_source_connector":"test-data-source-connector","database_name":"test-database-name","databricks_jdbc_url":"jdbc://test-databricks-jdbc-url","demo":true,"destination_location":"test-destination-location","hostname":"test-hostname","http_path":"test-http-path","is_free_trial":true,"is_sql_endpoint":true,"is_sql_warehouse":true,"jdbc_url":"jdbc://test-jdcc-url","oauth_u2m_app_id":"test-oauth-u2m-app-id","port":443,"service_principal_id":"test-service-principal-id","service_principal_oauth_secret":"test-service-principal-oauth-secret","user_info":{"databricks_organization_id":4645065419173783088,"databricks_user_id":5845867166711048519,"email":"[email protected]","first_name":"test-first-name","is_connection_established":false,"last_name":"test-last-name"},"workspace_id":1,"workspace_url":"https://test-workspace-url"}"""
5051

5152
test(
5253
"serialize and deserialize ConnectRequest: All the fields are provided"

0 commit comments

Comments
 (0)