checkSqlAuth() function in the
configuration file. This function should verify username and return
an object with password and security context.
If password returned from this function matches provided in connection string
user will be authenticated with provided security context.
Security Context (Row-Level Security)
Cube’s SQL API can also use the Security Context for Dynamic data model creation orqueryRewrite
property in your configuration file.
By default, the SQL API uses the current user’s Security Context, but this
behaviour can be modified so that certain users are allowed to switch. To do
this, we must first define which user is allowed to change Security Context:
Example
First, you need to define what user is allowed to change security context:contextToAppId(),
queryRewrite() and
checkSqlAuth() properties in your cube.js
configuration file:
securityContext in your data model:
Virtual User Filter
With the above now configured, we can query Cube using SQL with a user that is part of a trusted team:canSwitchSqlUser property in your cube.js
configuration file.
You can change security context for specific query via virtual filter on:
Session visibility
System views such aspg_catalog.pg_stat_activity hide some details, such as
query text, of sessions that belong to other users. A session belongs to the same
user only when both the user name and the security context returned by
checkSqlAuth() are equal. Users for which
checkSqlAuth() returns superuser: true can see details of all sessions.