Change to using group roles and dbowner roles
This commit is contained in:
parent
8fea0e21fb
commit
86abbc1fb3
15
main.go
15
main.go
@ -45,8 +45,11 @@ func main() {
|
||||
v []string
|
||||
)
|
||||
|
||||
v, _ = pairs[user]
|
||||
pairs[user] = append(v, db)
|
||||
// Groups
|
||||
if user != db {
|
||||
v, _ = pairs[user]
|
||||
pairs[user] = append(v, db)
|
||||
}
|
||||
|
||||
databases[db] = nil
|
||||
}
|
||||
@ -54,13 +57,15 @@ func main() {
|
||||
hbabuf.WriteString("local\tall\tpostgres\ttrust\n")
|
||||
|
||||
for d := range databases {
|
||||
initbuf.WriteString(fmt.Sprintf("CREATE DATABASE %s;\n", d))
|
||||
initbuf.WriteString(fmt.Sprintf("CREATE ROLE %s LOGIN;\n", d))
|
||||
initbuf.WriteString(fmt.Sprintf("CREATE DATABASE %s OWNER %s;\n", d, d))
|
||||
hbabuf.WriteString(fmt.Sprintf("hostssl\t%s\t%s\tall\tcert\tclientcert=verify-full\n", d, d))
|
||||
}
|
||||
|
||||
for u, v := range pairs {
|
||||
initbuf.WriteString(fmt.Sprintf("CREATE USER %s LOGIN;\n", u))
|
||||
initbuf.WriteString(fmt.Sprintf("CREATE ROLE %s LOGIN;\n", u))
|
||||
for _, d := range v {
|
||||
initbuf.WriteString(fmt.Sprintf("GRANT ALL PRIVILEGES ON DATABASE %s TO %s;\n", d, u))
|
||||
initbuf.WriteString(fmt.Sprintf("GRANT %s TO %s;\n", d, u))
|
||||
hbabuf.WriteString(fmt.Sprintf("hostssl\t%s\t%s\tall\tcert\tclientcert=verify-full\n", u, d))
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user