Snowflake Row-Level Security Using Row Access Policies - by Debi Prasad Mishra - Snowflake - Jan, 2023 - Medium
Snowflake Row-Level Security Using Row Access Policies - by Debi Prasad Mishra - Snowflake - Jan, 2023 - Medium
Limitations:
- Not supports the external tables as a mapping table in a row access policy.
- Not supports attaching a row access policy to the stream object itself.
- Future grants of privileges on row access policies are not supported.
- Future grants cannot be used with row access policies.
- Supports AND clauses in the subquery of the access policy. As a result of
this, it does not support multiple single values. For example, a user cannot
see data from multiple regions.
Business Scenario: Consider a user demographics data of an organization
split across multiple tables for customer 360 view analytics. Below are the
specific security use cases required to secure this data:
Demonstration/ Coding:
Step 1: Let’s create a sample table and insert some records as mentioned.
Search Medium Write Sign up Sign In
Insert statements
Table display
Step 4: Now it’s time for custom role creation, make sure the role name
should be same as the role mapping table as we defined.
Step 7: Finally let’s create a row access policy and add the policy using alter
statement as displayed below.
Policy association
Step 8: Now let’s start the code we developed. Please do follow my code and
will see the records returning from table.
Role having private banking records
Step 10: Let’s user account admin role to see the output.
No output
Why no records, very simple is not it? As we don’t have account admin role
defined in the role mapping table. That’s why restricts the output.
Step 11: Let’s insert below records into role mapping table and will see.
Conclusion: This explains, how row level security is defining & restricting
the rows in tables based on a users required level of access which helps in
preventing the sensitive data externally. Thank you for reading this post.
I hope this blog will help you to get understanding of the row access policy
usage and how efficiently we can build this fashion to protect data. Please
feel free to chat with me in case of more questions you have, on my twitter
handle or my LinkedIn or leave a comment below. Good luck!
Reference(s):
https://docs.snowflake.com/en/user-guide/security-row-intro.html
https://docs.snowflake.com/en/user-guide/security-row.html
Data Superhero
By signing up, you will create a Medium account if you don’t already have one. Review our Privacy Policy for more information about our
privacy practices.