Skip to content

Add group_id support for assuming a group during U2M OAuth login#1747

Open
grundprinzip wants to merge 2 commits into
databricks:mainfrom
grundprinzip:add-group-id-to-oauth
Open

Add group_id support for assuming a group during U2M OAuth login#1747
grundprinzip wants to merge 2 commits into
databricks:mainfrom
grundprinzip:add-group-id-to-oauth

Conversation

@grundprinzip

Copy link
Copy Markdown

Summary

Add the ability to assume a Databricks group during the user-to-machine (U2M) OAuth login flow. When configured, the numeric group ID is sent as the assume_group query parameter on the /oidc/v1/authorize request. The server validates that the user may assume the group and bakes the claim into the minted access token, so no header or parameter needs to be attached to subsequent API calls.

What changed

  • Add Config.AssumeGroupID (group_id in profiles, DATABRICKS_GROUP_ID env var) so .databrickscfg profiles can carry an optional group ID.
  • Add the u2m.WithAssumeGroup PersistentAuth option, injecting assume_group into the authorize URL for both the standard PKCE flow (appended to the authorization endpoint) and the discovery flow (set on the nested destination_url).
  • Reject assuming a group for account-level logins at construction time, mirroring the server-side workspace-only constraint.

Assuming a group is only supported for workspace-level U2M logins. The value is decided at login time; the SDK's runtime databricks-cli token source is unaffected.

How is this tested?

Added appropriate unit tests.

Co-authored-by: Isaac

Add the ability to assume a Databricks group during the user-to-machine
(U2M) OAuth login flow. When configured, the numeric group ID is sent as
the `assume_group` query parameter on the `/oidc/v1/authorize` request.
The server validates that the user may assume the group and bakes the
claim into the minted access token, so no header or parameter needs to be
attached to subsequent API calls.

Changes:
- Add `Config.AssumeGroupID` (`group_id` in profiles, `DATABRICKS_GROUP_ID`
  env var) so `.databrickscfg` profiles can carry an optional group ID.
- Add the `u2m.WithAssumeGroup` PersistentAuth option, injecting
  `assume_group` into the authorize URL for both the standard PKCE flow
  (appended to the authorization endpoint) and the discovery flow (set on
  the nested destination_url).
- Reject assuming a group for account-level logins at construction time,
  mirroring the server-side workspace-only constraint.

Assuming a group is only supported for workspace-level U2M logins. The
value is decided at login time; the SDK's runtime databricks-cli token
source is unaffected.

Co-authored-by: Isaac
Signed-off-by: Martin Grund <martin.grund@databricks.com>
The workspace-only guard for assume_group enumerated the account cases
(account argument and account-targeted discovery) as a blocklist, which
let a UnifiedOAuthArgument through. Unified arguments are account-capable
-- they carry an account ID and authenticate via the account/unified
endpoint -- so assume_group would be appended to a non-workspace authorize
URL and only rejected server-side, defeating the intended fail-fast.

Switch the guard to an allowlist: permit assume_group only for a workspace
argument or a non-account-targeted discovery login, and reject everything
else. This also prevents future account-capable argument types from
slipping through by default. Expand the validation test to cover workspace,
discovery, account, unified, and account-targeted discovery arguments.

Co-authored-by: Isaac
Signed-off-by: Martin Grund <martin.grund@databricks.com>
@github-actions

github-actions Bot commented Jul 3, 2026

Copy link
Copy Markdown

If integration tests don't run automatically, an authorized user can run them manually by following the instructions below:

Trigger:
go/deco-tests-run/sdk-go

Inputs:

  • PR number: 1747
  • Commit SHA: 29e3561ac4bbac80fef50f64020929ec8cb6953f

Checks will be approved automatically on success.

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.

1 participant