Sync: merge upstream v1.0.2 (privilege validation fix) - #3
Merged
Merged
Conversation
…n public schema Bug 1: Invalid privilege silently grants OWNER access - When PostgresUser.Spec.Privileges is set to an unknown value (e.g. 'VIEW' typo instead of 'READ'), the switch statement fell through to the default case which granted the OWNER group role. - Fix: Validate the privilege explicitly: require READ, WRITE, or OWNER. Unknown values now return an error instead of silently granting the highest access level. - Applied to both initial creation and privilege reconciliation paths. Bug 2: Default privileges never set when no schemas configured - When a Postgres CR is created without specifying spec.schemas, the privilege-setting loops iterated over an empty list and never executed. The database still has the default 'public' schema, but no ALTER DEFAULT PRIVILEGES was ever run, so objects created by one user remained invisible to other users with the appropriate role. - Fix: When no schemas are specified, default to configuring privileges on the 'public' schema which exists in every PostgreSQL database.
When a PostgresUser is created, the operator already sets ALTER ROLE SET ROLE so that objects are owned by the group role. However, if the user explicitly sets their role back to their own login identity (e.g., SET ROLE "user-role"), objects they create are owned by the user role, not the group role. Since ALTER DEFAULT PRIVILEGES was only set for group roles (owner, writer) as creators, the default privileges didn't apply and other roles couldn't access those objects. Fix: after creating the user role and granting group membership, also run ALTER DEFAULT PRIVILEGES FOR ROLE "user-role" for each schema, granting appropriate privileges to all three group roles (owner, reader, writer). This ensures that regardless of which identity the user creates objects under, the group roles can access them.
…resUser" This reverts commit e2a751d.
When no schemas are configured in a Postgres CR, the code now sets default privileges on the public schema (6 SetSchemaPrivileges calls: 1 schema x 2 creator roles x 3 target roles). Update test mocks to expect these calls.
…n public schema Bug 1: Invalid privilege value (e.g. VIEW typo) now returns error instead of silently granting OWNER access. Bug 2: Default privileges are set on public schema when no schemas are specified in the Postgres CR.
…n public schema Bug 1: Invalid privilege value (e.g. VIEW typo) now returns error instead of silently granting OWNER access. Bug 2: Default privileges are set on public schema when no schemas are specified in the Postgres CR.
…n public schema Bug 1: Invalid privilege value (e.g. VIEW typo) now returns error instead of silently granting OWNER access. Bug 2: Default privileges are set on public schema when no schemas are specified in the Postgres CR.
Bug 1: Invalid privilege value (e.g. VIEW typo) now returns error instead of silently granting OWNER access.
…rivileges fix: validate privileges in PostgresUser and set default privileges on public schema
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.
Changes
Syncs latest upstream changes from
gcaracuel/postgres-operator(v1.0.2):internal/controller/postgresuser_controller.go)After merge, create tag
v1.0.2onmasterto trigger the chart release workflow.