Apply row level security (RLS) in the Peliqan data warehouse
Install the Data App template “Row Level Security (RLS)”, update the configuration section and run the Data App. This will enforce RLS on a given table, directly in the Peliqan data warehouse.
Apply row level security (RLS) in code
If the above scenario is not possible (applying RLS directly in the DWH), you can also apply RLS in code, for example in a Data App or in a custom MCP Server.User authentication
In order to apply row-level permissions, each individual user must be authenticated and known to Peliqan. This means that a shared API key cannot be used. Instead SSO (Single Sign On) with OAuth is appropriate. More info: Publish & Embed apps Custom MCP with OAuthImplementation of RLS in code
Row level access is implemented by providing the client with a set of views, making sure each view has a fixed column on which permissions can be applied (e.g.user_role).
The views are invoked with a filter (e.g. a filter on user_role) and then prepended as CTEs to the SQL query that the client wants to execute.
Example
In this example, we assume that users have one single user role, user roles have permissions on zero, one or more departments and all resources are linked to one single department. Example description of the Data model which is exposed to the client:
Example table with mapping of permissions:
Example table with users, each user has one user_role:
| user | user_role |
|---|---|
| Bob | HR Manager |
| Anne | Finance Manager |
Final executed query for Anne, with user_role = ‘Finance Manager’:
Here is the source code for the custom MCP server, which applies the above Row Level Security method, see function
execute_query():
Click to expand code
Click to expand code
