postgres-operator/pkg
g2px1 ad3f4340bb
Skip ALTER ROLE when the stored SCRAM verifier already matches the password (#3171)
* Skip ALTER ROLE when the stored SCRAM verifier already matches the password

With password_encryption = scram-sha-256, syncSecrets compared the stored
rolpassword with a freshly generated verifier. SCRAM verifiers embed a
random salt, so the strings never match and every sync cycle re-issued
ALTER ROLE ... PASSWORD for every managed role, re-salting the verifier
each time. Besides the WAL and audit noise, this invalidates SCRAM
pass-through credentials cached by connection poolers (e.g. pgbouncer
behind auth_query), causing a short window of 'password authentication
failed' server logins after every sync.

Verify the stored hash against the desired password instead: for SCRAM
verifiers the salt and iteration count are taken from the stored value
and the derived keys are compared. Hashes whose type does not match the
configured password_encryption are still reported as outdated, so
switching between md5 and scram-sha-256 keeps re-hashing roles as
before.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* Update pkg/util/util.go

---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Co-authored-by: Ida Novindasari <idanovinda@gmail.com>
Co-authored-by: Felix Kunde <felix-kunde@gmx.de>
2026-08-20 09:05:19 +02:00
..
apis fix: rename module to github.com/zalando/postgres-operator/v2 (#3156) 2026-08-14 12:56:00 +02:00
apiserver fix: rename module to github.com/zalando/postgres-operator/v2 (#3156) 2026-08-14 12:56:00 +02:00
cluster fix: rename module to github.com/zalando/postgres-operator/v2 (#3156) 2026-08-14 12:56:00 +02:00
controller fix: rename module to github.com/zalando/postgres-operator/v2 (#3156) 2026-08-14 12:56:00 +02:00
generated fix: rename module to github.com/zalando/postgres-operator/v2 (#3156) 2026-08-14 12:56:00 +02:00
spec Fix operatorconfigurations CRD: NamespacedName must render as type string (#3145) 2026-07-28 16:02:59 +02:00
teams fix: rename module to github.com/zalando/postgres-operator/v2 (#3156) 2026-08-14 12:56:00 +02:00
util Skip ALTER ROLE when the stored SCRAM verifier already matches the password (#3171) 2026-08-20 09:05:19 +02:00