Skip to content

Add group configuration and auth validation - #307

Open
mihaimitrea-db wants to merge 1 commit into
mainfrom
rbac-group-configuration
Open

Add group configuration and auth validation#307
mihaimitrea-db wants to merge 1 commit into
mainfrom
rbac-group-configuration

Conversation

@mihaimitrea-db

@mihaimitrea-db mihaimitrea-db commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds group configuration and default-auth validation for group role assumption. This is the first of two stacked PRs and mirrors the configuration/validation boundary used by the Go Mod SDK.

Why

The SDK needs to resolve a requested group from supported configuration sources before OAuth credentials can request a group-scoped token. PAT and Databricks CLI authentication cannot assume a group, so allowing either strategy to silently ignore the setting would authenticate with the wrong identity.

This PR establishes the configuration and validation layer. The stacked follow-up, #308, adds assume_group to OAuth token requests.

What changed

Interface changes

  • Adds Profile.groupId, mapped to DATABRICKS_GROUP_ID and profile key group_id.
  • Adds M2mCredentialsOptions.groupId for the stacked OAuth implementation.
  • Adds GROUP_ROLE_UNSUPPORTED to DefaultCredentialsErrorCode.
  • Adds group-assumption capability metadata to default credential strategies.

Behavioral changes

  • Default credential discovery skips PAT and Databricks CLI when a non-empty group is configured.
  • Explicit PAT or Databricks CLI selection with a group fails before that provider is invoked.
  • Empty group values preserve the existing credential strategy order.
  • Default credentials continue to source configuration only from profiles and environment variables; explicit credentials are unaffected.

Internal changes

  • Adds focused profile-resolution, credential-chain, and real CLI rejection tests.
  • Adds a dedicated profile fixture for group configuration.
  • Does not modify generated client code or dependencies.

How is this tested?

Passed the full repository checks:

  • npm run format
  • npm run lint
  • npm run typecheck
  • npm test
  • npm run test:browser
  • npm run build

@mihaimitrea-db
mihaimitrea-db marked this pull request as ready for review August 26, 2026 16:40
@mihaimitrea-db mihaimitrea-db self-assigned this Aug 26, 2026

@parthban-db parthban-db left a comment

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.

LGTM modulo comments.

Comment on lines +124 to +151
it('skips unsupported strategies when a group is configured', async () => {
let unsupportedCalls = 0;
const creds = new DefaultCredentials(
[
configuredStrategy('pat', false, () => {
unsupportedCalls += 1;
}),
configuredStrategy('oauth-m2m'),
],
loaderFor({host: HOST, groupId: 'group-123'})
);

expect(await creds.authHeaders()).toEqual([
{key: 'X-Test-Strategy', value: 'oauth-m2m'},
]);
expect(unsupportedCalls).toBe(0);
});

it('preserves normal strategy ordering when the group is empty', async () => {
const creds = new DefaultCredentials(
[configuredStrategy('pat', false), configuredStrategy('oauth-m2m')],
loaderFor({host: HOST, groupId: ''})
);

expect(await creds.authHeaders()).toEqual([
{key: 'X-Test-Strategy', value: 'pat'},
]);
});

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.

These tests should be part of the above table test.

expect(loaderCalls).toBe(1);
});

it('does not configure a fallback after the selected strategy fails', async () => {

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

vi.unstubAllEnvs();
});

it('rejects grouped explicit CLI auth before invoking the CLI', async () => {

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 should be part of below table.

Comment on lines 86 to +92
describe('PROPERTY_DEFS', () => {
it('maps groupId to the Databricks environment and INI names', () => {
expect(GROUP_ID_DEF).toMatchObject({
envVar: 'DATABRICKS_GROUP_ID',
iniKey: 'group_id',
});
});

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 we should have existing table for this.

}
});

const emptyGroupCases: {

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 a different table? We should have an existing table for these cases.

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