Metabase impersonation with database roles

Metabase impersonation makes the database's own roles decide what each person sees, so existing row-level security applies to every question. This page covers the options, setup, limits and what to confirm before you rely on it.

On this page

When Metabase impersonation with database roles fits your access model

If your organization already enforces access in the data warehouse, impersonation lets you keep that model instead of building a second one inside Metabase. Impersonation maps user attributes to roles defined in the database, so the database's own privileges decide which rows and columns each person can see. Metabase does not re-create those rules in its own permission layer. This is the right starting point when your data platform team already owns grants, row-level security and audit trails, and when you want analysts and dashboard viewers to be bound by the same controls that apply to direct database connections.

Be aware that impersonation is a Pro or Enterprise feature, not part of Open Source or Starter. Confirm the plan you need before designing around it, and ask Metabase to confirm which edition covers your intended use. Supported databases are ClickHouse, MySQL, PostgreSQL, Redshift, Snowflake, SQL Server and Starburst/Trino. Check your exact database version and deployment against the Metabase impersonation documentation before committing, because some database features have their own version limits. For example, PostgreSQL row-level security policies on views work only on PostgreSQL 15 and later, so a PostgreSQL 14 estate would need a different design.

The mechanism applies to questions written in both the SQL editor and the query builder, because Metabase sets the database role before the query runs. That matters if your governance depends on consistent behavior across both entry points. Test both paths for each protected table, and make sure any saved question or dashboard that some users can open still resolves to the role of the person viewing it. If your team plans to use a single service account for convenience, this model will not give you per-person enforcement, so decide early whether your access model is per user or per group before you build the role mapping.

How a login reaches the database role

The flow starts when a person signs in to Metabase, either directly or through an identity provider that passes user attributes. Metabase maps those attributes to a role defined in the database, then sets that role before the query runs. The database applies its own row-level policies, and the filtered result returns to the question whether it was written in the SQL editor or the query builder. Check that the attribute values match the role mapping exactly and that the database role itself is granted only the access the person should have.

Impersonation sets the database role before each query, so the database filters rows.

Which impersonation setup fits each database and plan

This table compares the databases that support Metabase impersonation, the plan each one needs, and what your team should confirm in that database's role model before building. Use it to match your warehouse to a supported setup, then check the database-specific column before you rely on row-level policies.

DatabasePlan requirementWhat to confirm in its role model
ClickHousePro or EnterpriseConfirm that database roles can be set per session and that the roles you map to users restrict the tables and rows they should.
MySQLPro or EnterpriseConfirm which privileges your roles grant on schemas and tables, since MySQL has no native row-level security for this pattern.
PostgreSQLPro or EnterpriseConfirm roles and grants per schema, and use PostgreSQL 15 or later if you rely on row-level security policies on views.
PostgreSQL row-level security on viewsPro or Enterprise, PostgreSQL 15 or later onlyConfirm your server version first, then test that each mapped role returns only its own rows through the view.
RedshiftPro or EnterpriseConfirm the role and grant model for each schema and table, and test that restricted roles cannot reach other data.
SnowflakePro or EnterpriseConfirm role hierarchy, warehouse access and secure view or row access policy design with your Snowflake administrators.
SQL ServerPro or EnterpriseConfirm database roles, schema permissions and any row-level security predicates your team plans to use.
Starburst or TrinoPro or EnterpriseConfirm the access control rules in your Starburst or Trino configuration and how they map to the identities Metabase presents.

Setting up impersonation in six checks

This sequence takes a Metabase Pro or Enterprise instance from a plan check to a verified setup in which each user's database role decides which rows and columns they can read, in both SQL and query builder questions.

  1. Confirm the plan and database support

    Confirm that the Metabase instance runs on a Pro or Enterprise plan, since impersonation access is not available on Open Source or Starter. Then confirm that your database is one of the supported engines: ClickHouse, MySQL, PostgreSQL, Redshift, Snowflake, SQL Server or Starburst/Trino. If you plan to use PostgreSQL row-level security on views, confirm the server runs PostgreSQL 15 or later. Done when the plan and version are written down in the project record and a platform owner has signed off on them.

  2. Define database roles and row policies

    A database administrator creates one role per access level the business needs, grants each role only the schemas, tables or views it should read, and adds row-level security policies where rows must be filtered. Keep the policies on the database side so they hold no matter which tool connects. Done when a direct login as each role in the database client returns only the rows that role should see, and a role with no grant returns a permission error.

  3. Map user attributes to database roles

    A Metabase administrator sets the database connection to use impersonation and maps a user attribute, such as a region or tenant value that comes from your identity provider or the user's profile, to the matching database role name. Confirm the mapping for a small set of test accounts before enabling it for everyone. Done when each test account shows the expected role mapping in the admin settings and no account is left without a role.

  4. Grant the database permissions in Metabase

    Confirm the Metabase data permissions for each group so that impersonated users can reach the connected database and the collections they need. Review whether any group keeps broader direct access to the same database, because a broader group can bypass the intent of the mapping. Done when a permissions review lists each group, its data access level and the owner who approved it.

  5. Test SQL and query builder questions as different users

    Sign in as at least one test account per role and run the same question in both the SQL editor and the query builder. Compare the row counts and sample values with the results from the direct database login for that role. Metabase sets the role before the query runs, so both question types should match the database. Done when the counts and sample values match for both question types and every test account.

  6. Verify that a denied row never appears

    Choose a record that one test role must not see, then search for it through a dashboard, a saved question, a SQL question, an exported CSV and a search result as that user. Also check any cached results and any public or embedded content that uses the same data. Done when the denied record is absent from every surface and the test is recorded with the date, the tester and the Metabase version. Confirm the behavior for your exact version and any caching settings with your Metabase admin documentation before go-live.

Trade-offs of database-enforced access versus Metabase row filters

Choose database roles when the policy already lives in the database and your data team owns it. Impersonation moves the enforcement point into PostgreSQL, Snowflake, SQL Server or another supported engine, so the database's own grants and row-level security decide what each person sees. The policy is written once in SQL, reviewed with the same change process as other database objects, and applies to SQL editor and query builder questions alike because Metabase sets the role before the query runs. Metabase still controls who can be mapped to which role through user attributes, so the trade-off is not about who holds the final say but about where the rules are authored and tested.

Expect the database team to carry the maintenance load. Each role, grant and policy must be created, documented and kept in step with the people who join, move or leave. Confirm which engine and version you run before you commit, because PostgreSQL row-level security policies on views work only on PostgreSQL 15 and later. Audit also changes shape: query activity is recorded in the database's own logs under the impersonated role, so your security team needs to pull evidence from the warehouse or database as well as from Metabase. Ask who will own role changes, how access reviews will export grants, and whether the database audit settings capture the queries you need.

Changes reach users through the attribute mapping rather than a Metabase permission edit. When a policy changes in the database, the next query runs under the updated grant, but a change to a user's attribute or group membership in Metabase takes effect on that user's mapping. Test both paths on a non-production copy before rollout. The alternative, covered in the sibling row and column security topic, keeps filters inside Metabase and is often simpler for teams without database administrators on call. Choose impersonation when auditors and data owners expect enforcement at the source, and choose Metabase filters when the rules are mostly per-customer and the warehouse cannot host them cleanly.

Security and operational considerations for database roles

Impersonation moves access control into the database, so the database role becomes the security boundary. The cards below cover the risks that follow from that shift: the credentials that switch roles, how roles multiply, how policies are tested, the PostgreSQL version floor, audit trails across two systems, and keeping user mappings current as people move between teams.

Securing the connection that switches roles

Impersonation depends on a Metabase database connection that can set the role before each query runs. That connection is the most privileged path into your data, because any role it can assume is reachable from Metabase. Confirm that this connection's database login has only the grants needed to switch to the mapped roles, that its password is stored in your secrets manager or the Metabase configuration rather than in shared notes, and that it is rotated on a schedule you control. Ask your database administrator to test whether this login can reach roles outside the intended set.

Impersonation docs

Controlling role sprawl

Every distinct database permission set usually needs its own role, and teams tend to create one per request. Over time the database accumulates overlapping roles that nobody can explain, which makes access reviews slow and error-prone. Keep a short, named list of roles that map to business data scopes, document what each one grants, and remove roles that no user attribute references. Review the list whenever a new data source is connected, because each database has its own role catalog and its own owners.

Testing policies after schema changes

Row-level security policies and view definitions reference table columns. A renamed column, a new join or a dropped view can silently widen what a role sees or break a dashboard for everyone mapped to it. Add a test step to your change process that queries the affected tables as each representative role and compares row counts and visible columns against expected results. Run the same checks in a non-production Metabase instance before changes reach production, so a failed test blocks the release rather than surfacing in front of users.

Checking the PostgreSQL version floor

PostgreSQL row-level security policies on views only work on PostgreSQL 15 and later. If your team relies on view-based policies and runs an older major version, the isolation you designed may not exist. Before go-live, confirm the server version and plan the upgrade path if needed, and do not treat a policy that saves cleanly as proof that it filters rows. Verify behavior by running queries as a test role against the view and checking that the expected rows are returned and the rest are excluded.

Building audit trails across two systems

A question run through impersonation leaves a record in Metabase's activity data and a session or query record in the database, but the two logs use different identities and timestamps. Investigators need to tie a Metabase user to the database role used for each query. Decide where each log is retained and for how long, enable database query logging for the connection's role, and confirm that the Metabase user identity can be correlated with the database session. Test the trail with a known query before you rely on it for an access review.

Keeping mappings current as people move

Impersonation uses user attributes to pick a database role, so a person who changes teams keeps the old data scope unless the attribute is updated. Identity provider group changes, manual edits in Metabase and tickets to the database team can drift apart. Assign one owner for the attribute source of truth, sync it from your identity provider where your plan allows, and schedule a periodic review that compares active Metabase users with their mapped roles. Remove access from departing users as part of the same offboarding step that disables their sign-in.

Questions buyers ask before hiring help with impersonation

Does impersonation require a paid Metabase plan?

Yes. Impersonation access is available only on the Pro and Enterprise plans. The Metabase pricing page lists Pro at $575 per month, or $517.50 per month billed yearly, with the first 10 users included and additional users at $12 per month. Enterprise is priced by quote, starting at $20,000 per year. Row and column level permissions and SSO are also limited to these plans, so a single purchase often covers several governance features. Confirm current figures on the pricing page before budgeting, because plan terms can change.

What drives the subscription cost for a Pro or Enterprise plan?

The main driver is the plan you choose and the number of users. Pro is priced per month with a set number of included users and a per-user charge beyond that, and the yearly billing option lowers the monthly rate. Enterprise is quoted individually. Ask the vendor which features each tier includes, how user counts are measured, and whether a yearly commitment changes the rate. The DeployOpen implementation quote is separate and follows from the written scope of your databases, roles, and identity work.

How long does impersonation setup take?

The duration depends on how many databases you connect, how many roles already exist, and how clean your permission model is. Each database needs its roles mapped to user attributes, and each mapping needs testing against both SQL and query builder questions. A single database with a few well-defined roles is a much shorter task than several engines with overlapping grants. DeployOpen plans timelines in the written scope after reviewing your environment, so ask for a timeline tied to those counts rather than a generic estimate.

What does the work need from our DBA team?

Your DBAs own the database side of the design, so they are needed early. They define or confirm the roles, grants, and any row-level security policies, and they decide which role each Metabase user maps to. For PostgreSQL row-level security on views, check that your server runs PostgreSQL 15 or later. They also review how the Metabase connection account is granted permission to switch roles. Plan for DBA time in design review and in testing, not only at the end.

What does the work need from our identity team?

Impersonation depends on user attributes, so the identity team must make sure the attribute that selects a database role is delivered reliably. Depending on your setup, that means SAML, OIDC, JWT, or LDAP attribute sync, and those options are available on Pro or Enterprise. Confirm which identity provider you use, how group and attribute claims are issued, and who changes them when someone moves teams. Errors here often look like permission problems in Metabase.

Can our internal team set up impersonation without outside help?

Yes, if you have a team comfortable with Metabase administration, database grants, and your identity provider, and if the scope is small. Teams often struggle with the testing: they must confirm that each role returns the right rows through both the SQL editor and the query builder, and that no path bypasses the role. Outside help is most useful when you have many engines, complex role hierarchies, or audit evidence to produce. Compare the internal time cost with a fixed-scope quote, and ask any partner to name the test cases they will run.

Which databases support impersonation, and what should we check first?

Impersonation is available for ClickHouse, MySQL, PostgreSQL, Redshift, Snowflake, SQL Server, and Starburst/Trino. Check each engine's role model before you commit, because the features that enforce row rules differ. Confirm your exact database versions with the vendor, and test a representative user in a non-production environment before rollout. The Metabase impersonation documentation is the right starting point for the current requirements.

How DeployOpen works on this

DeployOpen plans and implements self-hosted Metabase inside your own infrastructure, including the database roles that impersonation depends on. We start from which users map to which database roles, then build and test the mapping against your databases before handing it over.

How we scope

  • Inventory the databases, schemas and roles that Metabase users need, and confirm each one supports impersonation on your plan
  • Map existing identity provider groups or user attributes to the database roles each person should assume
  • Confirm the PostgreSQL version before planning row-level security policies on views, which require PostgreSQL 15 or later
  • Agree the written scope, deliverables and timelines before work starts, since most engagements are fixed-scope

How we build

  • Create or adjust database roles and privileges so the database itself enforces what each role can read
  • Configure impersonation attributes in Metabase and test SQL editor and query builder questions under each role
  • Verify that row-level policies apply to saved questions, dashboards and embedded content using the same mapping
  • Confirm that a user with no mapped role cannot see data by default, and test the failure path

How we hand over

  • Document the role mapping, the attribute source, and the database grants that enforce it in your own runbook
  • Record the test cases and results used to confirm impersonation behavior for each supported database
  • Walk your database and platform teams through how to add a user, change a role and review access
  • Provide the configuration in a form your teams can keep under their own version control

How we support

  • Offer ongoing support, upgrades and continuous testing as a retainer after the initial handover
  • Retest impersonation paths after Metabase upgrades, database version changes or new role definitions
  • Review role grants periodically with your security team as users and data sources change
  • Ask for a quote built from the written scope, including what recurs under a retainer and what is one-time

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.