Repository navigation
refactor: extract a shared GRANT/REVOKE primitive for object privileges - #10829
Merged
Merged
Conversation
Contributor
|
❗ By default, the pull request is configured to backport to all release branches.
|
gbartolini
force-pushed
the
dev/10828
branch
2 times, most recently
from
June 3, 2026 08:36
f90555f to
0833459
Compare
Member
|
/test |
Contributor
|
@armru, here's the link to the E2E on CNPG workflow run: https://github.com/cloudnative-pg/cloudnative-pg/actions/runs/26880895469 |
armru
approved these changes
Jun 3, 2026
leonardoce
approved these changes
Jun 5, 2026
Generalise the database reconciler's privilege handling in preparation for schema-level and database-level grants. Extract applyObjectPrivilege from applyUsagePermissions, lifting the hardcoded USAGE keyword into a privilege parameter and making the log and error messages privilege-agnostic. applyUsagePermissions becomes a thin wrapper over it, so the FOREIGN DATA WRAPPER and FOREIGN SERVER callers and their tests are unchanged. Add a sanitizeGrantee helper (and a publicRole constant) that emits the PUBLIC pseudo-role verbatim rather than quoting it as the non-existent role "public". This is a minor, deliberate behaviour change on the existing USAGE path and is required to support REVOKE ... FROM PUBLIC, the most common database-hardening operation. Closes #10828 Assisted-by: Claude Signed-off-by: Gabriele Bartolini <[email protected]>
…pecs The new applyObjectPrivilege spec block closed the sqlmock DB in its AfterEach and asserted success, but go-sqlmock requires an explicit ExpectClose() for db.Close() to succeed. Without it, db.Close() returns "call to database Close was not expected" and all seven specs in the block fail. Match the convention of the other spec blocks in this file, which only assert ExpectationsWereMet() and do not close the mock DB. Signed-off-by: Armando Ruocco <[email protected]>
Fix a grammar slip ("grants or revoke" -> "revokes") and document that
the privilege and objectType arguments are interpolated into the SQL
verbatim, so callers must pass trusted in-code constants and never
user-controlled input.
Signed-off-by: Armando Ruocco <[email protected]>
Signed-off-by: Leonardo Cecchi <[email protected]>
Contributor
|
/test |
Contributor
|
@leonardoce, here's the link to the E2E on CNPG workflow run: https://github.com/cloudnative-pg/cloudnative-pg/actions/runs/27013702633 |
cnpg-bot
pushed a commit
that referenced
this pull request
Jun 5, 2026
…es (#10829) Generalise the database reconciler's privilege handling in preparation for schema-level and database-level grants. Extract applyObjectPrivilege from applyUsagePermissions, lifting the hardcoded USAGE keyword into a privilege parameter and making the log and error messages privilege-agnostic. applyUsagePermissions becomes a thin wrapper over it, so the FOREIGN DATA WRAPPER and FOREIGN SERVER callers and their tests are unchanged. Add a sanitizeGrantee helper (and a publicRole constant) that emits the PUBLIC pseudo-role verbatim rather than quoting it as the non-existent role "public". This is a minor, deliberate behaviour change on the existing USAGE path and is required to support REVOKE ... FROM PUBLIC, the most common database-hardening operation. Closes #10828 Assisted-by: Claude Signed-off-by: Gabriele Bartolini <[email protected]> Signed-off-by: Armando Ruocco <[email protected]> Signed-off-by: Leonardo Cecchi <[email protected]> Co-authored-by: Armando Ruocco <[email protected]> Co-authored-by: Leonardo Cecchi <[email protected]> (cherry picked from commit 28eb808)
cnpg-bot
pushed a commit
that referenced
this pull request
Jun 5, 2026
…es (#10829) Generalise the database reconciler's privilege handling in preparation for schema-level and database-level grants. Extract applyObjectPrivilege from applyUsagePermissions, lifting the hardcoded USAGE keyword into a privilege parameter and making the log and error messages privilege-agnostic. applyUsagePermissions becomes a thin wrapper over it, so the FOREIGN DATA WRAPPER and FOREIGN SERVER callers and their tests are unchanged. Add a sanitizeGrantee helper (and a publicRole constant) that emits the PUBLIC pseudo-role verbatim rather than quoting it as the non-existent role "public". This is a minor, deliberate behaviour change on the existing USAGE path and is required to support REVOKE ... FROM PUBLIC, the most common database-hardening operation. Closes #10828 Assisted-by: Claude Signed-off-by: Gabriele Bartolini <[email protected]> Signed-off-by: Armando Ruocco <[email protected]> Signed-off-by: Leonardo Cecchi <[email protected]> Co-authored-by: Armando Ruocco <[email protected]> Co-authored-by: Leonardo Cecchi <[email protected]> (cherry picked from commit 28eb808)
2 tasks done
leonardoce
pushed a commit
to BRGOVIND/cloudnative-pg
that referenced
this pull request
Nov 2, 2026
Restructure schema-level privilege management to a permissions stanza
keyed by privilege (usage, create), each entry reusing the existing
UsageSpec {name, type: grant|revoke} model, instead of the flat
usagePrivileges/createPrivileges lists. This aligns the API with the
design proposed in cloudnative-pg#10826 and keeps the surface consistent with the
foreign data wrapper / server usage permissions, building on the shared
applyObjectPrivilege primitive from cloudnative-pg#10829.
Regenerate deepcopy, CRD manifests and the API reference docs, and add
unit tests covering grant/revoke application on schema create and update.
Signed-off-by: B R GOVIND <[email protected]>
Open
2 tasks done
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.
Generalise the database reconciler's privilege handling in preparation for schema-level and database-level grants.
Extract applyObjectPrivilege from applyUsagePermissions, lifting the hardcoded USAGE keyword into a privilege parameter and making the log and error messages privilege-agnostic. applyUsagePermissions becomes a thin wrapper over it, so the FOREIGN DATA WRAPPER and FOREIGN SERVER callers and their tests are unchanged.
Add a sanitizeGrantee helper (and a publicRole constant) that emits the PUBLIC pseudo-role verbatim rather than quoting it as the non-existent role "public". This is a minor, deliberate behaviour change on the existing USAGE path and is required to support REVOKE ... FROM PUBLIC, the most common database-hardening operation.
Closes #10828
Assisted-by: Claude