Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 60 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
`baton-databricks` is a connector for Databricks built using the
[Baton SDK](https://github.com/conductorone/baton-sdk). It communicates with the
Databricks API, to sync data about Databricks identities (users, groups and
service principals), roles, workspaces and Unity Catalog metastores.
service principals), roles, workspaces and Unity Catalog metastores and catalogs.

Check out [Baton](https://github.com/conductorone/baton) to learn more about the project in general.

Expand Down Expand Up @@ -82,19 +82,22 @@ baton resources
- Users
- Roles
- Metastores
- Catalogs (under their metastore)

The connector fetches all resources from the account and every workspace the
service principal can access. To limit the scope, pass a comma-separated list of
workspaces to the `--workspaces` flag. Each entry can be a workspace name,
deployment name, or numeric workspace ID, matched case-insensitively.

`--workspaces` also scopes which metastores sync: only a metastore attached to a
listed workspace is synced, so narrowing the list removes the other metastores
and their grants from ConductorOne. A list that names no workspace on the
`--workspaces` also scopes which metastores and catalogs sync: only a metastore
attached to a listed workspace is synced, so narrowing the list removes the
other metastores and their grants from ConductorOne. Catalogs must also be
visible through a listed workspace. A list that names no workspace on the
account is rejected during credential validation, before any sync runs.

Metastores are Unity Catalog securables and are opt-in: the type stays off until
it is enabled for the connector in ConductorOne.
Metastores and catalogs are opt-in: each resource type stays off until enabled
for the connector in ConductorOne. Catalog sync uses the existing OAuth
credentials and configuration fields.

## Authentication

Expand All @@ -113,7 +116,8 @@ To instead exclude specific workspaces from the sync, pass them to the
list. Each entry can be a workspace name, deployment name, or numeric workspace
ID. Excluded workspaces and their roles are skipped entirely. A metastore
attached only to excluded workspaces is not synced, and its grants are removed
from ConductorOne.
from ConductorOne. Catalogs reachable only through excluded workspaces are also
left out.

## Incremental sync

Expand Down Expand Up @@ -232,6 +236,7 @@ account
├── group
├── service principal
└── metastore
└── catalog
```

A metastore exposes its privileges as entitlements (`CREATE_CATALOG`,
Expand All @@ -248,21 +253,62 @@ running one in scope where it can read every privilege, which it proves by
owning the metastore or by holding Admin directly on that workspace. Grant and
Revoke resolve the same route from the metastore id.

A metastore syncs through a running workspace in scope. The sync fails, naming
the metastore, while an attached workspace in scope is still provisioning, or
while the metastore's workspace list cannot be read.
A metastore is synced only while a workspace this sync can use is attached to
it. The connector never guesses when the answer is unknown:

| Attached workspace | Result |
|--------------------|--------|
| `RUNNING` and in scope | the metastore syncs through it |
| `PROVISIONING`, `NOT_PROVISIONED` | still changing, so the metastore is kept and the sync fails with `FailedPrecondition` until a workspace is `RUNNING` |
| `CANCELLING` | the workspace is being deleted and will not become `RUNNING`, so the metastore is kept and the sync fails until that workspace is gone or another attached one is `RUNNING` |
| `FAILED`, `BANNED`, or a status Databricks does not document | will not become `RUNNING`, so it is skipped; a metastore left with no other workspace is not synced |
| metastore workspace list unreadable (401, 403, 404) | unknown, so the metastore is kept and the sync fails naming that list |
| workspace permission list unreadable (401, 403, 404) | treated as not Admin on that workspace; the sync then fails with the usual missing-standing error, which does not name this list |

A metastore is left out of the sync only when the answer is known: every
attached workspace is out of scope or unusable. Leaving it out is what makes
ConductorOne remove it and its grants, so an unknown answer must not take that
path.

Catalog discovery visits every running workspace in scope attached to the
metastore, so catalogs bound to only some workspaces are included. Each catalog
appears once under its metastore. The built-in `system` catalog and all catalogs
Databricks identifies as `SYSTEM_CATALOG` (including `samples` when it has that
type) are excluded, regardless of ownership.

A workspace that refuses the catalog listing itself (401, 403, 404) leaves which
catalogs exist unknown, so the sync fails with `FailedPrecondition` naming the
metastore and that workspace instead of reporting a short list. Assign the
service principal **Admin** on that workspace, or leave it out with `workspaces`
or `databricks-exclude-workspaces`.

## Unity Catalog provisioning

A metastore privilege can be granted to and revoked from a user, group or
service principal. The `owner` entitlement is read-only: granting or revoking it
fails with an `InvalidArgument` error.
A metastore or catalog privilege can be granted to and revoked from a user,
group or service principal. The `owner` entitlement is read-only: granting or
revoking it fails with an `InvalidArgument` error.

If a catalog becomes unreachable, provisioning must distinguish deletion from
a workspace binding or visibility change. Requests can fail with
`FailedPrecondition` when deletion cannot be proved.

## Unity Catalog permissions

The service principal must own the metastore, or be assigned **Admin** directly
on at least one running workspace attached to it. Admin inherited only through a
group is not enough. Otherwise the sync fails naming the metastore.
group is not enough. Databricks answers an under-permissioned read with HTTP 200
and only the rows the caller may see, so the connector reads a metastore only
through a workspace that passes that check. When no attached workspace does, the
sync fails and ConductorOne keeps the grants it already has.

For a catalog's full grants list, the service principal must own the metastore
or the catalog itself, hold `MANAGE` on the catalog, or have Admin assigned
directly on the workspace whose admins group owns that catalog. Ownership is
matched against the service principal's own application ID, so a catalog owned
by a group it belongs to does not count. Workspace Admin alone does not
cover other catalogs. A non-owner using `MANAGE` also needs `USE_CATALOG` for
catalog discovery. An incomplete grants list fails the sync rather than
removing grants the connector cannot see.

The connector requests the `all-apis` OAuth scope. Each resource type declares
the scopes, roles and privileges it needs, so `./baton-databricks capabilities`
Expand Down
73 changes: 73 additions & 0 deletions baton_capabilities.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,79 @@
]
}
},
{
"resourceType": {
"id": "catalog",
"displayName": "Catalog",
"traits": [
"TRAIT_APP"
],
"annotations": [
{
"@type": "type.googleapis.com/c1.connector.v2.OptInRequired"
},
{
"@type": "type.googleapis.com/c1.connector.v2.CapabilityPermissions",
"permissions": [
{
"permission": "unity-catalog"
},
{
"permission": "scim"
},
{
"permission": "access-management"
},
{
"permission": "provisioning"
},
{
"permission": "Account admin"
},
{
"permission": "Workspace admin"
},
{
"permission": "USE_CATALOG"
}
]
},
{
"@type": "type.googleapis.com/c1.connector.v2.SkipEntitlements"
}
]
},
"capabilities": [
"CAPABILITY_SYNC",
"CAPABILITY_PROVISION"
],
"permissions": {
"permissions": [
{
"permission": "unity-catalog"
},
{
"permission": "scim"
},
{
"permission": "access-management"
},
{
"permission": "provisioning"
},
{
"permission": "Account admin"
},
{
"permission": "Workspace admin"
},
{
"permission": "USE_CATALOG"
}
]
},
"optInRequired": true
},
{
"resourceType": {
"id": "group",
Expand Down
3 changes: 2 additions & 1 deletion cmd/baton-databricks/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ import (
cfg "github.com/conductorone/baton-databricks/pkg/config"
"github.com/conductorone/baton-databricks/pkg/connector"
"github.com/conductorone/baton-sdk/pkg/config"
"github.com/conductorone/baton-sdk/pkg/connectorrunner"
)

var version = "dev"

func main() {
ctx := context.Background()
config.RunConnector(ctx, "baton-databricks", version, cfg.Config, connector.NewConnector)
config.RunConnector(ctx, "baton-databricks", version, cfg.Config, connector.NewConnector, connectorrunner.WithSessionStoreEnabled())
}
59 changes: 45 additions & 14 deletions docs/connector.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ sidebarTitle: "Databricks"
| Resource | Sync | Provision |
| :--- | :--- | :--- |
| Accounts | <Icon icon="square-check" iconType="solid" color="#c937ae"/> | <Icon icon="square-check" iconType="solid" color="#c937ae"/> |
| Catalogs | <Icon icon="square-check" iconType="solid" color="#c937ae"/> | <Icon icon="square-check" iconType="solid" color="#c937ae"/> |
| Groups | <Icon icon="square-check" iconType="solid" color="#c937ae"/> | <Icon icon="square-check" iconType="solid" color="#c937ae"/> |
| Metastores | <Icon icon="square-check" iconType="solid" color="#c937ae"/> | <Icon icon="square-check" iconType="solid" color="#c937ae"/> |
| Roles | <Icon icon="square-check" iconType="solid" color="#c937ae"/> | <Icon icon="square-check" iconType="solid" color="#c937ae"/> |
Expand All @@ -28,25 +29,29 @@ Revoking the workspace **member** entitlement removes the principal's entire wor

[This connector syncs non-human identities](/product/admin/nhi) and displays them on the **Identities overview** dashboard.

## Metastore access in C1
## Metastore and catalog access in C1

The connector syncs the Databricks [Unity Catalog](https://docs.databricks.com/aws/en/data-governance/unity-catalog/manage-privileges/privileges)
metastore as a C1 resource. Each privilege Databricks records on it
(`CREATE_CATALOG`, `READ_METADATA`, `USE_SHARE` and so on) becomes an
entitlement in C1, so you can review who holds it, request it, and revoke it
for users, groups and service principals. A grant held by a group is expandable
so C1 can resolve the group's members as holders. Ownership is shown as a
read-only `owner` entitlement — it cannot be granted or revoked through C1.
The connector syncs Databricks [Unity Catalog](https://docs.databricks.com/aws/en/data-governance/unity-catalog/manage-privileges/privileges)
metastores and the catalogs in them as C1 resources. Each privilege Databricks
records on one of them (`CREATE_CATALOG` on a metastore, `USE_CATALOG` or
`SELECT` on a catalog, and so on) becomes an entitlement in C1, so you can
review who holds it, request it, and revoke it for users, groups and service
principals. A grant held by a group is expandable so C1 can resolve the
group's members as holders. Ownership is shown as a read-only `owner`
entitlement — it cannot be granted or revoked through C1.

<Note>
The Metastores resource type is turned off by default. Turn it on from the connector's configuration page in C1.
The Metastores and Catalogs resource types are turned off by default. Turn on the ones you want from the connector's configuration page in C1. Catalogs sync under their metastore, so turn on Metastores as well as Catalogs; turning on Catalogs alone syncs nothing. Both use the same OAuth credentials; no additional configuration fields are needed.
</Note>

<Note>
**Notes on Unity Catalog access in C1:**

- Ownership is shown but cannot be provisioned. An owner that is not a Databricks account identity, such as a system account or a workspace admins group, is not shown at all.
- **MANAGE** and **ALL_PRIVILEGES** are not offered as entitlements, because Databricks rejects both at the metastore level.
- **MANAGE** and **ALL_PRIVILEGES** are not offered on a metastore, because Databricks rejects both at that level.
- A catalog is synced when any running workspace in scope attached to its metastore lists it, and the same catalog name is kept once per metastore. A catalog that only excluded workspaces can reach is not synced.
- The built-in `system` catalog is never synced, and neither is any other catalog Databricks marks as a system catalog, whoever owns it.
- If a catalog becomes unreachable, access requests can fail until the connector can distinguish deletion from a binding or visibility change. Catalog ownership or **MANAGE** alone cannot prove deletion; that check requires the **Metastore Admin**.
- Unity Catalog tags are not synced.
</Note>

Expand Down Expand Up @@ -176,7 +181,33 @@ There is no scope to pick in the console. The connector requests the `all-apis`
</Steps>

<Warning>
Without this, the metastore sync fails with a permission error naming the metastore. Databricks returns a partial privilege list rather than an error, and C1 would treat the missing grants as revoked.
Without workspace **Admin** or **Metastore Admin**, the metastore sync fails with a permission error naming the metastore. Databricks shows a caller only the grants it is allowed to see, so reporting that shorter list would make C1 treat the rest as revoked.
</Warning>

### Let the service principal read catalog privileges

Skip this section if you are not syncing catalogs, or if the service principal is already the **Metastore Admin**. Databricks shows a catalog's full privilege list only to the metastore admin, the service principal that owns the catalog itself, or a holder of **MANAGE** on it. The connector matches ownership against the service principal itself, so a catalog owned by a group it belongs to does not count. **Admin** assigned directly to the service principal on a workspace is enough only when the catalog is owned by that workspace's admins group (`_workspace_admins_<workspace>_<workspace id>`).

Otherwise, grant **MANAGE** and **USE CATALOG** on each catalog you want synced. **MANAGE** alone is not enough: Databricks does not return a catalog at all unless the caller is the metastore admin, owns it, or holds **USE CATALOG** on it, and a catalog it does not return is one C1 removes.

<Steps>
<Step>
In the workspace, open **Catalog Explorer** and open the catalog.
</Step>
<Step>
Select **Permissions**, then click **Grant**.
</Step>
<Step>
Select the service principal, check **MANAGE** and **USE CATALOG**, and confirm.
</Step>
</Steps>

<Warning>
For a discovered catalog that is not excluded by the system-catalog rule above, missing these permissions fails the sync naming that catalog. Databricks would otherwise return only the privileges the caller can see, and reporting that short list would make C1 delete the grants it cannot read. Failing keeps what C1 already has.

The connector asks every running workspace in scope attached to the metastore, so a catalog bound to one of those workspaces is included. A catalog the service principal cannot see on any of them is not, and C1 removes it and its grants.

If the service principal cannot list catalogs at all through one of those workspaces, the connector cannot tell which catalogs are there, so the sync fails naming the metastore and that workspace instead of removing the catalogs it could not list. Give the service principal **Admin** on that workspace, or leave that workspace out with **Workspaces** or **Exclude Workspaces**.
</Warning>

**Done.** Here's the set of credentials you'll need when setting up the connector:
Expand Down Expand Up @@ -234,8 +265,8 @@ To complete this task, you'll need:
<Step>
Optionally, narrow what the connector syncs:

- **Workspaces**: limit the sync to these workspaces, by workspace name, deployment name, or numeric workspace ID. This also scopes which metastores sync: only a metastore attached to one of these workspaces is synced, so narrowing the list removes the other metastores and their grants from C1.
- **Exclude Workspaces**: workspaces to leave out of the sync, by workspace name, deployment name, or numeric workspace ID. A metastore attached only to excluded workspaces is not synced either, and C1 removes it and its grants.
- **Workspaces**: limit the sync to these workspaces, by workspace name, deployment name, or numeric workspace ID. This also scopes which metastores and catalogs sync: only those a listed workspace reaches are synced, so narrowing the list removes the others and their grants from C1.
- **Exclude Workspaces**: workspaces to leave out of the sync, by workspace name, deployment name, or numeric workspace ID. A metastore or catalog that only excluded workspaces reach is not synced either, and C1 removes it and its grants.

Fill in **Workspaces** or **Exclude Workspaces**, not both.
</Step>
Expand Down Expand Up @@ -406,4 +437,4 @@ spec:

<Tip>
Stable binaries and container images for the Databricks connector are available from the [official download center](https://dist.conductorone.com/ConductorOne/baton-databricks).
</Tip>
</Tip>
Loading
Loading