Add support for protected roles#29
Open
joelynch wants to merge 1 commit into
Open
Conversation
Extends the existing protected-entity mechanism (the per-entity `Protected` flag plus the `PROTECTED_ACCESS_MANAGEMENT` global privilege, SQL keyword `PROTECTED`) to ROLE entities. A role marked `PROTECTED` can only be created, altered, renamed, replaced, dropped, moved between storages, or have its grants changed by a principal holding `PROTECTED_ACCESS_MANAGEMENT`. This lets service-managed roles exist as real SQL roles that ordinary cluster users cannot remove or tamper with. Role-specific changes: - Role: add a `protected_flag` member, an `isProtected()` override, and include the flag in `equal()`. - ASTCreateRoleQuery / ParserCreateRoleQuery: carry and parse the `PROTECTED` keyword on CREATE ROLE and `[NOT] PROTECTED` on ALTER ROLE, and round-trip it in `formatImpl`. - InterpreterCreateRoleQuery: require `PROTECTED_ACCESS_MANAGEMENT` when the statement sets `PROTECTED`; before any ON CLUSTER dispatch, read the existing role (ALTER and CREATE OR REPLACE) and require the privilege when the existing or new role is protected; re-check atomically via the `insertOrReplace` CheckFunc as defense-in-depth. - InterpreterShowCreateAccessEntityQuery: emit `PROTECTED` so the flag survives SHOW CREATE, ZooKeeper replication and backup/restore. - InterpreterMoveAccessEntityQuery: require the privilege when moving a protected role between storages. The storage-layer CheckFunc plumbing and the DROP and GRANT/REVOKE interpreters are entity-agnostic and already key off `isProtected()`, so DROP ROLE and GRANT/REVOKE on a protected role are covered without further changes. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Extends the existing protected-entity mechanism (the per-entity
Protectedflag plus thePROTECTED_ACCESS_MANAGEMENTglobal privilege, SQL keywordPROTECTED) to ROLE entities. A role markedPROTECTEDcan only be created, altered, renamed, replaced, dropped, moved between storages, or have its grants changed by a principal holdingPROTECTED_ACCESS_MANAGEMENT. This lets service-managed roles exist as real SQL roles that ordinary cluster users cannot remove or tamper with.Role-specific changes:
protected_flagmember, anisProtected()override, and include the flag inequal().PROTECTEDkeyword on CREATE ROLE and[NOT] PROTECTEDon ALTER ROLE, and round-trip it informatImpl.PROTECTED_ACCESS_MANAGEMENTwhen the statement setsPROTECTED; before any ON CLUSTER dispatch, read the existing role (ALTER and CREATE OR REPLACE) and require the privilege when the existing or new role is protected; re-check atomically via theinsertOrReplaceCheckFunc as defense-in-depth.PROTECTEDso the flag survives SHOW CREATE, ZooKeeper replication and backup/restore.The storage-layer CheckFunc plumbing and the DROP and GRANT/REVOKE interpreters are entity-agnostic and already key off
isProtected(), so DROP ROLE and GRANT/REVOKE on a protected role are covered without further changes.Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
...
Documentation entry for user-facing changes