Assign SUPERUSER to human users by default.

This commit is contained in:
Oleksii Kliukin
2017-05-12 11:41:27 +02:00
committed by Murat Kabilov
parent 34ac47aed9
commit 45fcb2adc9
2 changed files with 3 additions and 1 deletions
+1
View File
@@ -50,6 +50,7 @@ func (c *Cluster) createPgUser(user spec.PgUser) (isHuman bool, err error) {
if user.Password == "" { if user.Password == "" {
isHuman = true isHuman = true
flags = append(flags, "SUPERUSER")
flags = append(flags, fmt.Sprintf("IN ROLE \"%s\"", constants.PamRoleName)) flags = append(flags, fmt.Sprintf("IN ROLE \"%s\"", constants.PamRoleName))
} else { } else {
isHuman = false isHuman = false
+2 -1
View File
@@ -270,6 +270,7 @@ func (c *Cluster) deleteSecret(secret *v1.Secret) error {
} }
func (c *Cluster) createUsers() error { func (c *Cluster) createUsers() error {
// TODO: figure out what to do with duplicate names (humans and robots) among pgUsers
for username, user := range c.pgUsers { for username, user := range c.pgUsers {
if username == constants.SuperuserName || username == constants.ReplicationUsername { if username == constants.SuperuserName || username == constants.ReplicationUsername {
continue continue
@@ -283,7 +284,7 @@ func (c *Cluster) createUsers() error {
userType = "robot" userType = "robot"
} }
if err != nil { if err != nil {
return fmt.Errorf("Can't create %s user '%s': %s", userType, username, err) c.logger.Warnf("Can't create %s user '%s': %s", userType, username, err)
} }
} }