cancel
Showing results for 
Search instead for 
Did you mean: 
Technical Blog
Explore in-depth articles, tutorials, and insights on data analytics and machine learning in the Databricks Technical Blog. Stay updated on industry trends, best practices, and advanced techniques.
cancel
Showing results for 
Search instead for 
Did you mean: 
adnan_alvee
Databricks Employee
Databricks Employee

Access problems in Databricks are rarely about missing permissions. More often they are about people carrying every permission they have ever been given into every session. Someone gets added to a finance readers group for a quarter-end project; nobody removes them, and two years later they can still see payroll while debugging a marketing pipeline. As those permissions add up, admins have to keep track of who has access to what and whether they still need it.

Databricks Role-based access control (RBAC), now GA, solves this robustly. You pick a role from the top of the workspace menu, and your active permissions are replaced with the role's permissions for the duration of the session. Everything else you normally carry around is gone until you switch back to your identity. One hat at a time, and the audit log shows the hat and who wore it.

Switching in is a hover over the workspace name at the top of the left menu. The roles you can assume show up in a submenu. Pick one and the page reloads as that identity. There's also a URL parameter, aid=<group-id> which you add to
https://<workspace-url>/?o=<workspace-id>&aid=<group-id>
That drops you straight into a role when you open the link. Handy for sending someone into the right role instead of telling them which one to pick.

adnan_alvee_0-1793554023199.png

 

Figure 1: Assume a role from workspace selection window 

 

This post walks through how it works, how to set it up, and three situations where it solves problems that groups alone can't solve.

One Idea to get right

In Databricks, your user identity accumulates permissions additively, through permissions you are directly granted or through permissions granted to the groups you belong to. This model optimizes for collaboration within a single workspace. But over time, as team members change projects or duties, group memberships and inherited permissions simply accumulate, unless there is some process or automation in place to audit and remove permissions that users no longer need. This leads to permission sprawl and makes it difficult to enforce strict least-privilege security controls over sensitive data.

Assuming a role replaces your active set of permissions with the role’s permissions. If the role can't see a table, you can't see it either once you are assuming it, even if you could five minutes ago under your own user identity. You hold only one role at a time.

 

adnan_alvee_1-1793554023193.png

Figure 2. Group memberships follow you additively everywhere. A role restricts permissions exclusively to the active session.

 

If you have experience with sudo or role switching on other platforms, the process will feel familiar. The key difference compared to standard group membership lies in its opt-in model. Group membership provides constant, standing access. Conversely, a role grants access strictly for the duration it is active, and every time you switch into it, all audit events for activities performed capture both your user (identity_metadata.run_by) and the role (identity_metadata.run_as).

Setting it up takes three boxes

The setup Databricks recommends has three parts, and it is simpler than it sounds.

Create an account-level group with no members. This is your role. Give it a prefix so nobody mistakes it for a normal group. The docs suggest a role- and it's a good habit. Grant the role whatever access it needs on the data and on workspace assets.

GRANT USE CATALOG, USE SCHEMA, SELECT
  ON CATALOG client_acme
  TO `role-client-acme`;


Then grant the group that holds the actual people, say consulting-team, the Assume permission on your newly created role. You can do that from Workspace → Settings → Identity and access → Groups, the group’s permissions page in the account console, or through the Access Control API. Every member of consulting-team can now switch roles to role-consulting-acme, gaining the benefits of RBAC.

adnan_alvee_2-1793554023194.png

 

Figure 3. People live in the member group. Grants live on the empty role. Assume connects the two.

 

The role group stays empty. Add a person to it directly and they get standing access to its permissions, which means they can reach the data without ever assuming the role.

Role groups are intended to be assumed, rather than used to grant standing access through direct membership. If you want to catch cases where someone is added directly, a lightweight scheduled check can flag any role-* group with members for review. Treat it as a guardrail, not a blanket rule that every membership is a mistake, as some may be intentional.

 

import re, sys
from databricks.sdk import WorkspaceClient

client = WorkspaceClient()

bad = [
   (g.display_name, len(g.members or []))
   for g in client.groups.list()
   if re.match(r"^role-", g.display_name or "") and g.members
]

if bad:
   print("Role groups with standing members:", bad)
   sys.exit(1)

print("PASS: all role groups are empty")

 

If your groups live in Entra ID or Okta, same idea. Make the empty group there, sync it with AIM/SCIM, grant Assume in Databricks on the empty group with permissions.

adnan_alvee_3-1793554023194.pngFigure 4. Group permission types with Manage and Assume

 

Three places it fits

1. A consulting team with four clients

Take an analyst who works with four clients, each with a separate catalog. With group membership, she belongs to four groups, and every notebook session may technically have access to all four catalogs.

With RBAC, you can enforce exclusive access: the analyst can switch between four client-specific roles. She selects role-client-acme to work on Acme data. The role name remains visible so she can switch to another client when needed, but the other three catalogs are not available to the active session. They are not hidden or filtered; they are outside the permissions granted by the current role.

When she switches to the next client role, the active role's catalog access changes accordingly. The previous client's data is no longer reachable in that session until she explicitly switches back to the corresponding role.

 

adnan_alvee_4-1793554023194.png

Figure 5. One person, one client at a time. The other catalogs don't exist for that session.

 

The audit trail reads cleanly too. Every query shows run_as as the client role, so when a client asks who touched their data, the answer is the role, and run_by tells you which person was behind it.

2. PII that stays masked until you ask for it

Say PII columns are tagged in Unity Catalog and masked for everyone with a Attribute-based access control (ABAC) policy. The policy has one exception, a role called role-pii-viewer. Under your own name you see asterisks. Assume the role and you see the real values.

CREATE FUNCTION mask_pii(val STRING) RETURNS STRING
  DETERMINISTIC RETURN '***';
 
CREATE POLICY pii_default_mask
  ON CATALOG customer_data
  COLUMN MASK mask_pii
  TO `account users`
  EXCEPT `role-pii-cleared`
  FOR TABLES
  MATCH COLUMNS has_tag('pii') AS pii_col
  ON COLUMN pii_col;


The useful part is the posture it creates. Looking at raw PII becomes something you deliberately do and that gets logged, instead of something you can always do and nobody tracks.

The whole thing is only as good as what you can show an auditor. Both halves of the identity land in system.access.audit, so a “who looked at raw PII this week” query looks like this.

SELECT event_time,
       identity_metadata.run_by          AS person,
       identity_metadata.run_as          AS role,
       action_name,
       request_params['full_name_arg']   AS object_name
FROM   system.access.audit
WHERE  service_name = 'unityCatalog'
  AND  identity_metadata.run_as = 'role-pii-viewer'
  AND  event_time > current_timestamp() - INTERVAL 7 DAYS
ORDER BY event_time DESC;

run_by is the human or a SP. run_as is the hat they were wearing. That pair is the sentence you want to be able to say out loud in a review. 

3. Jobs and notebooks that belong to the team

Anything you create while assuming a role is owned by the role. Notebooks, SQL queries, warehouses, jobs. A job created as a role gets its Run as set to the role automatically.

Take a data platform team whose nightly loads are owned by role-data-platform and run as role-data-platform. When someone leaves, nothing breaks and nobody has to reassign forty jobs on a Friday afternoon. Anyone who has done that reassignment knows why this matters.

The same principle applies to Genie. Genie One at the workspace level, Genie Code, and Genie Agents support RBAC, so while you’re acting as a role, they can access only the data and assets that role is allowed to access. Genie chats you create while acting as the role are owned by that role, too. That keeps access and ownership aligned with the team role and not just with the individual who started the chat.

Where to start

Don't migrate everything. Pick the one dataset you're most nervous about. Make the empty role, grant it access, and give your team Assume. Then test it with someone who has no direct access to that dataset, a regular team member rather than an admin or the catalog owner, since those get through on their own permissions and prove nothing. Under their own user the query should be denied. Assume the role and it should work. Once that holds, walk your existing groups and ask one question of each. Is membership supposed to mean standing access? If yes, leave it alone. If no, it wants to be a role.

 

Databricks Official Documentation: https://docs.databricks.com/aws/en/security/auth/rbac