Skip to main content

Identity attributes in Unity Catalog ABAC policies (Beta)

Beta

Identity attributes in ABAC policies are in Beta. To use them, an account admin must turn on the Identity Attributes in ABAC Policies preview from the account console Previews page. See Manage account-level previews.

What are identity attributes?​

Identity attributes are properties of a user, such as their department or country. Each attribute has a name and a value. For example, a user's department can be hr and their country can be germany.

Use them in row filter and column mask policies to control access based on who runs the query, without creating separate groups for every combination of user properties. For example, you can mask employee addresses for everyone outside hr, or filter sales transactions by the user's country and division.

Identity attributes are synced from your identity provider. The following attributes are available: department, division, organization, costCenter, title, userType, locality, region, and country.

Identity attribute functions​

Identity attributes can have multiple values. For example, a user's region attribute can contain both EMEA and US.

Use the following functions to evaluate identity attributes in a policy's WHEN clause or in its filtering or masking UDF:

Function

Use it in

Returns

has_identity_attribute_value('attribute_key', 'value')

WHEN clause

true if the user has the specified value for the given attribute key. If the user has no value for the attribute, it returns false.

has_identity_attribute_tag_match('attribute_key', 'tag_key')

WHEN clause

true if the user has a value for the given attribute key that matches the value of the governed tag with key tag_key, set directly or inherited from the schema or catalog. If the user has no value, it returns false.

user_identity_attribute_values(session_user(), 'attribute_key')

UDF

ARRAY<STRING> containing all values of the user's attribute. If the attribute has no values for the user, the array is empty.

Function

Use it in

Returns

has_identity_attribute_value('attribute_key', 'value')

WHEN clause

true if the user has the specified value for the given attribute key. If the user has no value for the attribute, it returns false.

has_identity_attribute_tag_match('attribute_key', 'tag_key')

WHEN clause

true if the user has a value for the given attribute key that matches the value of the governed tag with key tag_key, set directly or inherited from the schema or catalog. If the user has no value, it returns false.

user_identity_attribute_values(session_user(), 'attribute_key')

UDF

ARRAY<STRING> containing all values of the user's attribute. If the attribute has no values for the user, the array is empty.

To mask data for everyone outside hr, including users without a department value, use WHEN NOT has_identity_attribute_value('department', 'hr'). See Row filter and column mask policy evaluation and runtime behavior.

user_identity_attribute_values only supports returning the attribute values of the user running the statement (session user), so its first argument must be session_user(). See Authorized user and session user. To use this function in a policy UDF, the querying users need serverless compute or Databricks Runtime 19 and above. Queries from other compute types throw an error.

Attribute names and values are case-sensitive. For example, finance and Finance don't match.

Policy examples​

The following examples show how to use these functions in a policy. For the full steps, see Create a policy with identity attributes:

  • Mask employee addresses for everyone outside hr. In the WHEN clause of the column mask policy: WHEN NOT has_identity_attribute_value('department', 'hr')
  • Filter sales transactions based on the country of the querying user. In the row filter UDF: RETURN array_contains(user_identity_attribute_values(session_user(), 'country'), row_country);
  • Mask columns unless the user's department owns the table. In the WHEN clause of the column mask policy: WHEN NOT has_identity_attribute_tag_match('department', 'owning_department')

Configure attribute syncing from your identity provider​

An account admin can configure attribute syncing from your identity provider through the mechanism that you already use for identity management: automatic identity management or System for Cross-domain Identity Management (SCIM) provisioning. To check which mechanism your account uses, click Security in the account console and open the Identity provider setup tab.

Databricks supports only SCIM 2.1 for attribute sync.

  1. Check whether your SCIM connector already sends attributes:
    1. As an account admin, log in to the account console.
    2. In the sidebar, click User management.
    3. On the Users tab, find your own user.
    4. Click the Identity attributes tab.
  2. If the attributes that you need already have values, you don't need to configure anything else. If they show an en dash (–), Databricks hasn't received them from your identity provider. Add the missing attributes to the SCIM connector app there, and make sure that the connector uses account SCIM 2.1. For the steps for Okta and Microsoft Entra ID, see Configure a SCIM connector.
  3. Send a test user to Databricks, and check the user's Identity attributes tab again. Most identity providers can push a user's information on demand, such as Provision on demand in Microsoft Entra ID or Force Sync in Okta. Attributes appear about five minutes after your identity provider sends them. If it can't push on demand, attributes typically arrive within 40 minutes.

Create a policy with identity attributes​

The following steps show how to create a row filter policy and a column mask policy with identity attributes. With the row filter policy, users see only the rows where the country column matches their own country, in every table in the prod.sales schema with a column tagged country_column. With the column mask policy, everyone outside the hr department sees **** in columns tagged pii with the value address.

Before you start, confirm with an account admin that identity attributes have been configured. See Configure attribute syncing from your identity provider.

  1. Create a UDF that uses the user_identity_attribute_values function to check whether the row's country matches any of the user's country identity attribute values. Users without a value for this attribute can't access any rows:

    SQL
    CREATE FUNCTION prod.governance.is_users_country(row_country STRING)
    RETURNS BOOLEAN
    RETURN array_contains(
    user_identity_attribute_values(session_user(), 'country'),
    row_country
    );
  2. Tag the country column and create a row filter policy. The policy uses the country_column tag to identify which columns to pass to the UDF:

    SQL
    ALTER TABLE prod.sales.orders
    ALTER COLUMN country SET TAGS ('country_column' = '');

    CREATE POLICY orders_by_country
    ON SCHEMA prod.sales
    ROW FILTER prod.governance.is_users_country
    TO `account users` EXCEPT `sales_admins`
    FOR TABLES
    MATCH COLUMNS has_tag('country_column') AS country_col
    USING COLUMNS (country_col);

    You can also create the policy in Catalog Explorer or with the REST API. See Create and manage row filter and column mask policies.

  3. Test the policy. Query prod.sales.orders. You see only the orders for your own country. Members of sales_admins still see all rows, because the group is in the policy's EXCEPT clause.

Use identity attributes to prevent group and policy explosion​

When access depends on multiple user properties, such as department, country, or division, group-based access control can quickly become difficult to manage. You may need a separate group for every combination of values, along with hardcoded group checks in UDFs or separate policies. As new values are added, the number of groups and the effort to maintain access rules grow.

Identity attributes let you use user properties already available in your identity provider directly in access rules, without the need to represent every combination through groups.

The following examples show how this simplifies row filters and column masks.

Row filtering example​

Suppose users should see only the rows in prod.sales.orders for their own division and country, and there are 5 divisions and 10 countries.

If you encode this through one group for each combination of division and country, you end up with 50 groups, and you need to hardcode all of them in the UDF through is_account_group_member(). This setup is cumbersome to create and maintain: when a country or division is added, you need new groups and new checks in the UDF.

SQL
-- With groups: one group and one check for each division x country combination
CREATE FUNCTION prod.governance.filter_orders(row_division STRING, row_country STRING)
RETURNS BOOLEAN
RETURN
(is_account_group_member('retail_france') AND row_division = 'retail' AND row_country = 'france')
OR (is_account_group_member('retail_germany') AND row_division = 'retail' AND row_country = 'germany')
OR (is_account_group_member('wholesale_france') AND row_division = 'wholesale' AND row_country = 'france')
-- ... 47 more checks, one for each remaining division and country group

With identity attributes you can write a single policy with a simple UDF that doesn't need to be changed when new countries or divisions are added.

SQL
-- With identity attributes: one check that covers all values for division and country
CREATE FUNCTION prod.governance.filter_orders(row_division STRING, row_country STRING)
RETURNS BOOLEAN
RETURN array_contains(user_identity_attribute_values(session_user(), 'division'), row_division)
AND array_contains(user_identity_attribute_values(session_user(), 'country'), row_country);

Column masking example​

Suppose everyone can query the tables in the prod catalog, but columns tagged confidential should be visible only to users in the department that owns the table, and there are 8 departments. Each table has a governed tag owning_department.

If you encode this through groups, you need 8 policies, one for each department, that masks the confidential columns for everyone outside that department's group. When a department is added, you need a new group and a new policy.

SQL
-- With groups: one group and one policy for each department
CREATE POLICY mask_confidential_finance
ON CATALOG prod
COLUMN MASK prod.governance.mask_value
TO `account users` EXCEPT `finance` -- The finance group is exempt from the mask...
FOR TABLES
WHEN has_tag_value('owning_department', 'finance') -- ...for the tables that they own
MATCH COLUMNS has_tag('confidential') AS confidential_col
ON COLUMN confidential_col;

-- Repeated 7 more times, each with another department in both EXCEPT and WHEN

With identity attributes you can express this in a single policy that compares the table's owning_department tag with the user's department. The policy doesn't need to be changed when new departments are added.

SQL
-- With identity attributes: one policy for every department
CREATE POLICY mask_confidential_outside_owning_department
ON CATALOG prod
COLUMN MASK prod.governance.mask_value
TO `account users`
FOR TABLES
WHEN NOT has_identity_attribute_tag_match('department', 'owning_department')
MATCH COLUMNS has_tag('confidential') AS confidential_col
ON COLUMN confidential_col;

Limitations​

  • has_identity_attribute_value and has_identity_attribute_tag_match are not supported in GRANT or DENY policies.
  • Identity attributes are available on users only, not on service principals or groups.
important

Don't store sensitive information in identity attributes. Their values can be read through the account APIs.

Additional resources​