Lookup Tables for RLS
Row level security filters with any user attribute.
A lookup table allows you to use more user attributes for row level security filtering. For example, without a lookup table you can only use an email field for row level security. By defining a lookup table with user information, you will be able to use any attribute in the table as the RLS filter.
A lookup table can be defined for each of your datasources. The email field is a must have on your lookup table.
Let’s look at an example lookup table.
user_id | name | role | region | |
---|---|---|---|---|
101 | User1 | user1@acme.com | engineer | east |
102 | User2 | user2@acme.com | sales | west |
103 | User3 | user3@acme.com | desginer | central |
104 | User4 | user4@acme.com | engineer | east |
105 | User5 | user5@acme.com | engineer | west |
Specifying a lookup table for a datasource
- Visit the datasource page on the Zing console.
- Click on the Settings button on your datasource.
- Turn on the toggle for Row Level Security.
- Select the table you want to set as the lookup table for the datasource and the email field in that table.
- Now you can specify any filter on your charts/tables as mentioned here using the attributes in your lookup table. For example, if you want to apply the RLS filter on the user’s ID, the filter on the WHERE condition should be {{zing.user.user_id}}. Filtering by the region would be possible by specifying the filter as {{zing.user.region}}.