I am trying to create a database with a role, that can connect to and view that database only.
How I went about it:
_, err = db.Exec("CREATE DATABASE " + database.Name + " ENCODING 'utf8' LC_COLLATE 'en_US.UTF-8'")
_, err = db.Exec("CREATE ROLE " + database.User + " WITH LOGIN PASSWORD '" + database.Password + "'")
_, err = db.Exec("REVOKE ALL PRIVILEGES ON DATABASE " + database.Name + " FROM PUBLIC")
_, err = db.Exec("GRANT ALL PRIVILEGES ON DATABASE " + database.Name + " TO " + database.User)
The problem is that my role can connect to postgres via:
psql -U haruki -W -h localhost
Which is okay, but it can list all databases with its corresponding permissions, even though it cannot connect to them.
Is there any way I can prevent the user from listing all databases? Or perhaps allow logging in only with the -d flag?