Skip to content

Sync: merge upstream v1.0.2 (privilege validation fix) - #3

Merged
gcaracuel merged 19 commits into
masterfrom
sync/upstream-20260812
Aug 13, 2026
Merged

gcaracuel merged 19 commits into
masterfrom
sync/upstream-20260812

Conversation

@gcaracuel

Copy link
Copy Markdown

Changes

Syncs latest upstream changes from gcaracuel/postgres-operator (v1.0.2):

After merge, create tag v1.0.2 on master to trigger the chart release workflow.

…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.
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
@gcaracuel
gcaracuel merged commit ed5664d into master Aug 13, 2026
4 checks passed
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.

1 participant