mirror of
https://github.com/zalando/postgres-operator.git
synced 2026-10-06 05:21:53 +02:00
Configure pg_hba in the local postgresql configuration of Patroni. (#361)
Previously, the operator put pg_hba into the bootstrap/pg_hba key of Patroni. That had 2 adverse effects: - pg_hba.conf was shadowed by Spilo default section in the local postgresql configuration - when updating pg_hba in the cluster manifest, the updated lines were not propagated to DCS, since the key was defined in the boostrap section of Patroni. Include some minor refactoring, moving methods to unexported when possible and commenting out usage of md5, so that gosec won't complain. Per https://github.com/zalando-incubator/postgres-operator/issues/330 Review by @zerg-junior
This commit is contained in:
+3
-2
@@ -1,7 +1,7 @@
|
||||
package util
|
||||
|
||||
import (
|
||||
"crypto/md5"
|
||||
"crypto/md5" // #nosec we need it to for PostgreSQL md5 passwords
|
||||
"encoding/hex"
|
||||
"math/rand"
|
||||
"regexp"
|
||||
@@ -48,7 +48,7 @@ func PGUserPassword(user spec.PgUser) string {
|
||||
// Avoid processing already encrypted or empty passwords
|
||||
return user.Password
|
||||
}
|
||||
s := md5.Sum([]byte(user.Password + user.Name))
|
||||
s := md5.Sum([]byte(user.Password + user.Name)) // #nosec, using md5 since PostgreSQL uses it for hashing passwords.
|
||||
return md5prefix + hex.EncodeToString(s[:])
|
||||
}
|
||||
|
||||
@@ -120,6 +120,7 @@ func MapContains(haystack, needle map[string]string) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// Coalesce returns the first argument if it is not null, otherwise the second one.
|
||||
func Coalesce(val, defaultVal string) string {
|
||||
if val == "" {
|
||||
return defaultVal
|
||||
|
||||
Reference in New Issue
Block a user