How can I restrict the privileges of a PostgreSQL role to access only functions
already present in a schema, so no individual SELECT
or INSERT
queries are allowed?
I've created a new user:
$ createuser --no-superuser --createdb --no-createrole --pwprompt myuser
$ createdb --encoding UTF8 --owner myuser mydatabase
Then, I added my schema with all tables and functions for table access:
$ psql -h localhost -U myuser -d mydatabase -a -f myschema.sql
Is it sufficient do drop all privileges for role myuser
and them just:
myuser=> GRANT EXECUTE ON ALL FUNCTIONS IN SCHEMA myschema TO myuser;
Or should I create a distinct role? Can this role access a schema whom it is not the owner of?
myuser
is meant to be restricted, why do you make it the owner of the database and schema objects in the first place? You should probably use a separate administrative role to create objects, then only grant specific privileges tomyuser
.permission denied for schema myschema
for a distinct role, despiteUSAGE
rights have been granted.