Requirements
To follow the steps in this guide, you’ll need permissions in Omni that allow you to:- Edit models
- Create and/or edit user attributes
Best practice when controlling data access with access_grants and access_filters is to ensure the user attributes do not have default values set.
Granting topic & field access with access grants
To apply an access grant, the first step is to create anaccess_grant in the model file. You’ll need to specify a user_attribute to use and the allowed_values that are necessary to gain access under the grant.
For example, the nw_region access grant will grant access to users with a region user attribute that has a value of washington, idaho, oregon, wyoming, or alaska:
Model file
Omni system attributes in access grants
Omni system attributes can be used in access grants. In the following example, theomni_is_org_admin attribute is used to control the topics that are accessible only to Admin users.
Model file
Topic access grants
After an access grant is created in the model file, you can userequired_access_grants in topic files to apply specific access grants to individual topics:
Topic file
required_access_grants must match an existing access_grant in the model file.
Default access grants for topics
Usingdefault_topic_required_access_grants in the model file allows you to set a default required access grant for all topics contained in the model, unless others are applied. In the following example, finance will be the default access grant for the topics in the model:
Model file
finance access grant will be used because a required_access_grants isn’t defined:
products topic
Overriding default topic access grants
You can override a default topic access grant if needed:-
To allow all users to see a topic, add a blank
required_access_grantsparameter: order_items topic -
To override the default and use a different access grant, add a
required_access_grantsparameter and include the access grant you want to use: users topic
Table (view) access grants
To apply an access grant to a table (database view), use therequired_access_grants parameter in a view file:
View file
Field access grants
If you need to restrict access to specific fields instead of an entire view, you can apply access grants to individual dimensions and measures with therequired_access_grants parameter:
View file
Conditional access grants
You can also conditionally allow access when specifyingrequired_access_grants by using pipes (|) and ampersands (&) to create OR and AND conditions, respectively.
required_access_grants parameter is supported.
AccessBoostable access grants
By default, access grant checks will restrict query access even if AccessBoost is enabled on a dashboard. For content built on topics or views that use access grants, you’ll need to add anaccess_boostable: true property to the grant to enable permission boosting via AccessBoost:
Model file
Granting row-level access with access filters
Row-level permissions are specified at the topic level with theaccess_filters parameter or at the model level with the default_topic_access_filters parameter.
Like access grants, access filters use user attributes to determine if a user should have access to the data in a given row. You can also selectively permit access for users if needed.
Fields in a topic
Use theaccess_filter parameter in a topic file to specify a list of fields in the topic where access should be limited.
In this example, the order_items topic will be filtered so that each brand can only see their own transactions and the associated metadata for each transaction.
order_items topic
orders > inventory_items > products and use a filter like the following, which limits access to rows with a brand value that matches the user attribute:
Default access filters for topics
Usingdefault_topic_access_filters in the model file allows you to set default access filters for all topics contained in the model, unless others are applied. In the following example, an access filter for the products.brand field is defined:
Model file
access_filters are defined:
order_items topic
Default access filters with unscoped table references
default_topic_access_filters can also be applied with an unscoped table reference, allowing for a common field across multiple tables to be applied universally with ease.
The following example demonstrates how to apply an access_filter for the user_id field to both the order_items and the users topics, allowing for a more generalized approach:
Model file
order_items topic, which includes a user_id field:
order_items topic
users topic, which includes a user_id field:
users topic
Permit access for specific users
There may be situations where you want to generally restrict data for a field, but still allow specific users like Admins to access all data for the field. To achieve this, you can set a special value for the user’s user attribute and then specify it in the access filter with thevalues_for_unfiltered parameter:
customer user attribute with a value of is_admin. Note: Users who don’t have a defined value for the user attribute - in this case, customer = null will receive an error. Omni expects a value for any assigned access filter.