Set up two postgresql databases.
In one of them you have
the tables and the secret views, and restrict access to the secret
views to a 'postgres_restricted' user.
In the other one database define:
create extension postgres_fdw;
create server compras_y_costos foreign data wrapper postgres_fdw options (host 'localhost', port '5432', dbname 'database_which_holds_the tables_and_the_secret_view');
create user mapping for postgres server ..... options (user 'postgres_restricted', password 'postgres_restricted_password');
create foreign table remote_reference__to_secret_view ()...
create server compras_y_costos foreign data wrapper postgres_fdw options (host 'localhost', port '5432', dbname 'database_which_holds_the tables_and_the_secret_view');
create user mapping for postgres server ..... options (user 'postgres_restricted', password 'postgres_restricted_password');
create foreign table remote_reference__to_secret_view ()...
Then grant public access to the views via the wrapper.
this should work fine.
El vie, 10 dic 2021 a la(s) 11:33, Frank Eckes (frank.eckes@xxxxxxxxx) escribió:
Hi everybody,
To access data in a PostgreSQL database I write queries which contains
the business rules
how t access data. This is working fine and also the permission are
working fine.
But I found out that a user can see the complete business rules in a
query or a procedure which is
a big security issue.
Is there e possibility that I can hide the definition and th user can
only see the data or can execute
the procedure/function.
And even worse, if i define a foreign server (e.g ORACLE) everybody can
see the credentials in a user mapping
which should not be allowed. This might be a show stopper of using
PostgreSQL in security environments.
Regards
Frank Eckes