How about using proxy users to avoid "create any table"? #164
Replies: 3 comments 1 reply
-
Apologies for the late reply, I just came back from parental leave Let me check and test what you have proposed here. I think the ANY privilege was introduced in 23ai. Are you using 23ai ? |
Beta Was this translation helpful? Give feedback.
-
Hi @aosingh, Regards |
Beta Was this translation helpful? Give feedback.
-
Oh, I am referring to schema-level privilege which was introduced in 23ai. Not on the whole database. -- Tables, views, materialized views
grant select any table on schema app_schema to testuser2;
grant insert any table on schema app_schema to testuser2;
grant update any table on schema app_schema to testuser2;
grant delete any table on schema app_schema to testuser2;
-- Procedures, functions and packages
grant execute any procedure on schema app_schema to testuser2;
grant execute any procedure on schema app_schema to t1_schema_role; |
Beta Was this translation helpful? Give feedback.
-
How about using proxy users and post_hooks to avoid the authorisation ‘Create any Table’ when using numerous different schemas.
Currently it is quite ugly that you either have to work with existing tables in other schemas or you have to grant the ‘create any table/view’ permission. DBAs are extremely reluctant to grant this right.
The idea is to open and use a connection with the respective proxy user depending on the target schema of the model. The target schema is known and easily accessible via the syntax username[proxy_account] without further configuration.
If the ‘select any table’ right is also to be avoided, a PostHook can simply be configured for each model, which grants the corresponding ‘select’ right to the DownStream schemas (e.g. Stage=>Core=>Mart). The route via a role (e.g. dbt_oper) is unfortunately not possible, as tables or views are also created via CTAS using this grant. In my opinion, however, this is not possible.
The code customisation would be minimal.
Following modifications need to be done:
This is only needed to store the proxy_user-property (~schema differs from username of connection)
and determine the need of an proxy-user for this connection:
Afterwards find out if the connection fits our purposes (username=proxy_user), otherwise reconnect with correct credentials
3. modify open(cls, connection)
use proxy_user for username when given:
Should work like a charme :-)
Beta Was this translation helpful? Give feedback.
All reactions