cancel
Showing results for 
Search instead for 
Did you mean: 
Administration & Architecture
Explore discussions on Databricks administration, deployment strategies, and architectural best practices. Connect with administrators and architects to optimize your Databricks environment for performance, scalability, and security.
cancel
Showing results for 
Search instead for 
Did you mean: 

SCIM not returning account-level groups for Databricks App users

juan_maedo
Contributor

We’re building an Azure Databricks App for a company use case, designed as a self-service tool for a group of non-technical users (around 100-200).

The main idea is that these users don’t have any permissions on the workspace. Access is granted only through an Entra ID group synced at the account level. This group is granted the CAN USE permission directly on the app through the Databricks Asset Bundle used for deployment, so users can log in successfully, and we are correctly capturing and recording their emails in the insights and logs. The Entra ID groups are not nested.

The problem comes with segregating sections or functionalities within the app. We can’t resolve the users’ security groups, because both the groups and the users exist only at the account level (the groups are added in the account groups section).

So far we have tried the workspace-level SCIM endpoint /api/2.0/preview/scim/v2/Me and the account-level SCIM endpoint /api/2.0/accounts/{account_id}/scim/v2/Users, both with the user’s OBO token (X-Forwarded-Access-Token) and with the app service principal token. We also tried making the app identity a workspace admin and granting it CAN MANAGE on the account group. None of these return the users’ group membership, so we can’t implement the segregation properly.

However, when a user has also been added to the workspace through other technical workspace groups, SCIM does return their group membership. Our hypothesis is that the workspace-level SCIM API only returns groups assigned to the workspace, so account-only groups are not visible to the app, even when the app identity has elevated permissions.

We are trying to avoid adding the users’ groups to the workspace, to keep things simple and maintain a scalable permissions model. Also, have a table of groups member its not maintainable for us their sync. 

  • Is there a supported way for a Databricks App to resolve the account-level group membership of the current user without assigning those groups to the workspace?
  • Which api or permission of the App Identity could resolved this problem?
  • If any its possible, what is the recommended pattern for role-based access within a Databricks App for account-only users?  
1 REPLY 1

SumeshKashyap
Valued Contributor III

Your hypothesis is right. Workspace SCIM (including /Me) only returns groups that are assigned to the workspace. Your account SCIM calls failed because both tokens you tried are workspace-scoped. The user's OBO token and the app service principal's token are issued by the workspace, and the accounts host rejects them no matter what workspace admin or group permissions the identity has. To read account-level membership without assigning the groups to the workspace, call the account SCIM API with an account-level OAuth token. That token comes from a dedicated service principal with the account admin role.

 

Setup

 

1. In the account console, create a service principal (e.g. app-group-reader), give it the Account admin role, and generate an OAuth secret for it at the account level.

2. Store the client ID and secret in a secret scope and add them as secret resources on the app, so they reach the app as env vars.

3. In the app, get the user's email from the X-Forwarded-Email header. Resolve the user's account ID, then check it against the members of your role groups:

 

import os, time

from databricks.sdk import AccountClient

 

acct = AccountClient(

    host="https://accounts.azuredatabricks.net",

    account_id=os.environ["DATABRICKS_ACCOUNT_ID"],

    client_id=os.environ["GROUP_READER_CLIENT_ID"],

    client_secret=os.environ["GROUP_READER_SECRET"],

)

 

ROLE_GROUPS = {"app-admins": "<group-id>", "app-analysts": "<group-id>"}  # account group IDs

_cache = {"ts": 0, "members": {}}

 

def _members():

    if time.time() - _cache["ts"] > 600:  # refresh every 10 min

        _cache["members"] = {

            role: {m.value for m in (acct.groups.get(id=gid).members or [])}

            for role, gid in ROLE_GROUPS.items()

        }

        _cache["ts"] = time.time()

    return _cache["members"]

 

def roles_for(email: str) -> set[str]:

    users = list(acct.users.list(filter=f'userName eq "{email}"', attributes="id"))

    if not users:

        return set()

    uid = users[0].id

    return {role for role, ids in _members().items() if uid in ids}

 

Cache the user ID per session as well, so a page load doesn't make an account API call.

 

Notes

 

- Only check the handful of groups that drive features in your app. Don't enumerate everything a user belongs to.

- If your Entra groups are nested, members can contain groups. Flatten them, or use flat groups for app roles.

- Keep the secret out of the app code and the bundle. The secret resource is the right place for it.

- If an account admin SP is too much privilege for your security team, the alternative is to skip Databricks and ask Entra directly. Use Microsoft Graph checkMemberGroups for the user's email, with an app registration that has GroupMember.Read.All. Since the groups come from Entra anyway, that's equally valid.

 

Docs: https://learn.microsoft.com/en-us/azure/databricks/dev-tools/auth/oauth-m2m (account-level token section) and https://learn.microsoft.com/en-us/azure/databricks/dev-tools/databricks-apps/auth