changeset 431:7cd1536a6797

Replaced sys-admin db user with a metamorphic one.
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Mon, 20 Aug 2018 15:29:57 +0200
parents cdf18ef0ecd6
children 5f5b3ca0c9fe
files cmd/gemma/geoserver.go pkg/config/config.go
diffstat 2 files changed, 11 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/cmd/gemma/geoserver.go	Mon Aug 20 14:57:00 2018 +0200
+++ b/cmd/gemma/geoserver.go	Mon Aug 20 15:29:57 2018 +0200
@@ -20,8 +20,8 @@
 )
 
 const (
-	startupSQL = `SET SESSION AUTHORIZATION "${user,%s}"`
-	closeupSQL = `RESET SESSION AUTHORIZATION`
+	startupSQL = `SET ROLE "${sys_admin,%s}"`
+	closeupSQL = `RESET ROLE`
 )
 
 func basicAuth(user, password string) func(req *http.Request) {
@@ -135,10 +135,11 @@
 					{"port", config.DBPort()},
 					{"database", config.DBName()},
 					{"schema", databaseScheme},
-					{"user", config.SysAdmin()},
-					{"passwd", config.SysAdminPassword()},
+					{"user", config.MetamorphDBUser()},
+					{"passwd", config.MetamorhpDBPassword()},
 					{"dbtype", databaseType},
-					{"Session startup SQL", fmt.Sprintf(startupSQL, config.SysAdmin())},
+					{"Session startup SQL",
+						fmt.Sprintf(startupSQL, config.MetamorphDBUser())},
 					{"Session close-up SQL", closeupSQL},
 				},
 			},
--- a/pkg/config/config.go	Mon Aug 20 14:57:00 2018 +0200
+++ b/pkg/config/config.go	Mon Aug 20 15:29:57 2018 +0200
@@ -30,8 +30,8 @@
 func ServiceUser() string     { return viper.GetString("service-user") }
 func ServicePassword() string { return viper.GetString("service-password") }
 
-func SysAdmin() string         { return viper.GetString("sys-admin") }
-func SysAdminPassword() string { return viper.GetString("sys-admin-password") }
+func MetamorphDBUser() string     { return viper.GetString("metamorph-db-user") }
+func MetamorhpDBPassword() string { return viper.GetString("metamorph-db-password") }
 
 func MailHost() string     { return viper.GetString("mail-host") }
 func MailPort() uint       { return uint(viper.GetInt32("mail-port")) }
@@ -138,9 +138,6 @@
 	str("service-user", "postgres", "user to do service tasks")
 	str("service-password", "", "password of user to do service tasks")
 
-	str("sys-admin", "postgres", "user to do admin tasks")
-	str("sys-admin-password", "", "password of user to do admin tasks")
-
 	str("mail-host", "localhost", "server to send mail with")
 	ui("mail-port", 465, "port of server to send mail with")
 	str("mail-user", "gemma", "user to send mail with")
@@ -155,6 +152,9 @@
 	str("geoserver-password", "geoserver", "GeoServer password")
 	strSl("geoserver-tables", geoTables, "tables to publish with GeoServer")
 
+	str("metamorph-db-user", "", "Metamorphic database user")
+	str("metamorph-db-password", "", "Metamorphic database user password")
+
 	str("proxy-key", "", `signing key for proxy URLs. Defaults to random key.`)
 	str("proxy-prefix", "", `URL prefix of proxy. Defaults to "http://${web-host}:${web-port}"`)