Benefits
- Row-level security: Database policies applied to each role are enforced automatically, since Omni queries run as the connection’s database user.
- Audit logging: Database logs reflect which role executed each query, providing a clear trail for compliance.
- Resource management: Assign different compute warehouses or resource pools to specific roles to manage performance and cost.
Prerequisites
- Administrative access to your database to create roles and service accounts
- Organization Admin permissions in Omni
Steps
Create the primary connection
Create a connection using credentials for the most permissive role — the one that is a superset of all other roles you plan to use. This connection will serve as the base for your model.Refer to the Database setup guides for instructions specific to your data warehouse.
Create a connection for each additional role
For every additional database role you want to map, create a separate Omni connection using that role’s service account credentials.Each connection must be the same database type as the primary connection. The schemas should be structurally identical — if a model references an object that doesn’t exist in a role’s connection, queries for users on that connection will fail.
Add role connections as environments
- Navigate to the primary connection’s settings page.
- Click the Environments tab.
- Click New Environment and select one of the role connections you created in the previous step.
- Repeat for each additional role connection.
- Click Save.
Create the user attribute
Create a user attribute that will map each Omni user to their database role:
- Navigate to Settings > Attributes.
- Click New Attribute.
- Choose a Reference name that describes the role mapping (for example,
db_role). You’ll use this reference name when configuring the connection in the next step. - Set a Default Value that corresponds to the primary connection’s role, so users without an explicit assignment fall back to the default.
- Click Save.
- Manually in Settings > Attributes > Users tab
- Via the API using the User attributes API
- Via SCIM through an identity provider like Okta, which can sync role assignments automatically
Enable dynamic environment assignment
- Navigate back to the primary connection’s Environments tab.
- Toggle Allow environments to be assigned dynamically to on.
- In the User attribute field, enter the reference name of the user attribute you created in the previous step.
- In the Values for the default connection field, enter the value that maps to the primary connection.
- For each environment connection, enter the user attribute value that should route users to that connection.
- Click Update.
Clean up extra models
When you created the additional connections in step 2, Omni may have auto-generated a model for each one. Since all roles share the primary connection’s model, delete any models that were created for the non-primary connections.
- Navigate to Settings > Connections.
- Click the connection for one of the non-primary roles.
- If a model was auto-generated, click Delete model on the connection’s settings page.
- Repeat for each non-primary connection.
Next steps
- Verify the setup by impersonating a user with a non-default role and running a test query
- Review your data models to confirm they don’t reference objects that are unavailable to restricted roles
- If using an identity provider, configure SCIM to automatically sync role assignments as users are provisioned