CXH-1584: Surface database-level access in redshift connector by al-conductorone · Pull Request #134 · ConductorOne/baton-sql · GitHub
Skip to content

CXH-1584: Surface database-level access in redshift connector#134

Merged
al-conductorone merged 4 commits into
mainfrom
cxh-1584-redshift-database-level-access
Jun 3, 2026
Merged

CXH-1584: Surface database-level access in redshift connector#134
al-conductorone merged 4 commits into
mainfrom
cxh-1584-redshift-database-level-access

Conversation

@al-conductorone

Copy link
Copy Markdown
Contributor

Redshift database-level access now shows up correctly in C1; the connector now reads the privilege types Redshift actually emits (TEMP, USAGE, CREATE) on each database, instead of an alias the underlying view does not use.

The database connect entitlement was always empty: Redshift's
svv_database_privileges never emits CONNECT, only TEMP/USAGE/CREATE
granted to named principals or PUBLIC. The grant query filtered on
CONNECT and the map only handled user/role/group identity types.

Rename the entitlement to access (which matches what it actually
represents), widen the query to privilege_type IN ('TEMP', 'USAGE',
'CREATE'), and update the three map entries' entitlement_id. Keep
immutable: true until per-privilege provisioning is validated end to
end. PUBLIC rows are intentionally skipped here; modeling PUBLIC needs
a synthetic principal and is tracked as a follow-up.

Verified against the local stub: grants now emit
database:dev:access:user:alice, database:dev:access:group:analysts,
and database:analytics:access:role:editor, with PUBLIC rows skipped.
@al-conductorone al-conductorone requested a review from a team June 2, 2026 20:32
@linear-code

linear-code Bot commented Jun 2, 2026

Copy link
Copy Markdown

@al-conductorone al-conductorone requested a review from btipling June 2, 2026 20:32
@al-conductorone al-conductorone requested a review from a team June 2, 2026 20:32
SELECT database_name, privilege_type, identity_name, identity_type
FROM svv_database_privileges
WHERE privilege_type = 'CONNECT'
WHERE privilege_type IN ('TEMP', 'USAGE', 'CREATE')

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.

🟡 Suggestion: The IN ('TEMP', 'USAGE', 'CREATE') filter can return up to three rows per (principal, database) pair, and all three map to the single access entitlement. This will create duplicate grants for the same principal+entitlement when a user holds more than one of these privileges. Consider deduplicating with SELECT DISTINCT identity_name, identity_type, database_name (dropping privilege_type from the SELECT) so each principal gets one grant per database.

purpose: permission
grantable_to: [user]
slug: connect
slug: 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.

🟡 Suggestion: Renaming the entitlement slug from connect to access is a B2 breaking change — any existing deployments that had synced grants under the old slug would see those grants disappear and new ones appear under access. The PR description asserts svv_database_privileges never actually emitted CONNECT rows, so no grants would have been synced. If that's confirmed, this is safe. Worth a note in the PR description that this is intentionally not backwards-compatible.

@github-actions

github-actions Bot commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot 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.

No blocking issues found.

@github-actions github-actions Bot 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.

No blocking issues found.

svv_database_privileges emits one row per (principal, database,
privilege_type), so a principal holding TEMP+USAGE+CREATE produced
three identical grants (same principal, same `access` entitlement,
same database). The c1z store dedups them on write via the unique
index on (external_id, sync_id), so the end state was correct, but
the connector still spent cycles emitting and serializing the
duplicates.

Switch the SELECT to DISTINCT on (identity_name, identity_type,
database_name) so a principal contributes exactly one row regardless
of how many of TEMP/USAGE/CREATE they hold.
…abase-level-access

# Conflicts:
#	examples/redshift-test.yml
@al-conductorone al-conductorone merged commit 6d89f8c into main Jun 3, 2026
9 checks passed
@al-conductorone al-conductorone deleted the cxh-1584-redshift-database-level-access branch June 3, 2026 23:27

@github-actions github-actions Bot 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.

No blocking issues found.

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.

4 participants