postgres-operator/pkg/util
g2px1 6e65436624 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 19:28:36 +02:00
..
config fix: rename module to github.com/zalando/postgres-operator/v2 (#3156) 2026-08-20 19:28:36 +02:00
constants feat (operator): add support for IRSA (aws resources access) (#3128) 2026-07-15 18:19:10 +02:00
filesystems fix: rename module to github.com/zalando/postgres-operator/v2 (#3156) 2026-08-20 19:28:36 +02:00
httpclient Modernize code generation (#3003) 2026-01-09 14:22:10 +01:00
k8sutil fix: rename module to github.com/zalando/postgres-operator/v2 (#3156) 2026-08-20 19:28:36 +02:00
nicediff End 2 End tests speedup (#1180) 2020-10-28 10:04:33 +01:00
patroni fix: rename module to github.com/zalando/postgres-operator/v2 (#3156) 2026-08-20 19:28:36 +02:00
retryutil Fix typo (#965) 2020-05-12 09:20:09 +02:00
ringlog fix comments for ringlogger 2017-09-26 13:12:38 +02:00
teams fix: rename module to github.com/zalando/postgres-operator/v2 (#3156) 2026-08-20 19:28:36 +02:00
users Skip ALTER ROLE when the stored SCRAM verifier already matches the password (#3171) 2026-08-20 19:28:36 +02:00
volumes fix: rename module to github.com/zalando/postgres-operator/v2 (#3156) 2026-08-20 19:28:36 +02:00
util.go Skip ALTER ROLE when the stored SCRAM verifier already matches the password (#3171) 2026-08-20 19:28:36 +02:00
util_test.go Skip ALTER ROLE when the stored SCRAM verifier already matches the password (#3171) 2026-08-20 19:28:36 +02:00