---
title: Identity attributes in Unity Catalog ABAC policies (Beta)
description: Use identity attributes, such as a user's department or country from your identity provider, to filter rows and mask columns in Unity Catalog ABAC policies.
canonical_url: https://docs.databricks.com/aws/en/data-governance/unity-catalog/abac/identity-attributes
---

# Identity attributes in Unity Catalog ABAC policies (Beta)

> [!NOTE]
> **Beta**
>
> Identity attributes in ABAC policies are in [Beta](https://docs.databricks.com/aws/en/release-notes/release-types.md). 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](https://docs.databricks.com/aws/en/admin/workspace-settings/manage-previews.md#account).

## <a id="what-are-identity-attributes" />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`.

## <a id="functions" />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')`](https://docs.databricks.com/aws/en/sql/language-manual/functions/user_identity_attribute_values.md) | 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](https://docs.databricks.com/aws/en/data-governance/unity-catalog/abac/policy-evaluation.md).

`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](https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-authorized-user.md). To use this function in a policy UDF, the querying users need serverless compute or [Databricks Runtime 19](https://docs.databricks.com/aws/en/release-notes/runtime/19.md) 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.

### <a id="policy-examples" />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](https://docs.databricks.com/aws/en/data-governance/unity-catalog/abac/identity-attributes.md#create-policy):

* 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')`

## <a id="configure-syncing" />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.

### SCIM

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](https://docs.databricks.com/aws/en/admin/users-groups/identity-attributes/provision-with-scim.md#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.

### Automatic identity management

With automatic identity management, you choose which attributes to sync with the **Identity Attribute Control List** preview. A user's attributes are updated within about five minutes after the user signs in.

1. Turn on the **Identity Attribute Control List** preview:
   1. As an account admin, log in to the account console.
   2. In the sidebar, click **Previews**.
   3. Turn on **Identity Attribute Control List**.
2. Select the attributes to sync:
   1. In the sidebar, click **Security**.
   2. Click the **Identity provider setup** tab.
   3. In the **Identity management** section, under **Configure identity attributes**, click **Manage attributes**.
   4. Select the attributes that you want to use, such as **Department** and **Country**, and click **Save**.
3. Confirm that the attributes synced:
   1. In a separate tab, log out and log back in to the workspace. Attributes are refreshed on login.
   2. In the account console sidebar, click **User management**.
   3. On the **Users** tab, find your own user.
   4. Click the **Identity attributes** tab. Attributes without a value show an en dash (–).

## <a id="create-policy" />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](https://docs.databricks.com/aws/en/data-governance/unity-catalog/abac/identity-attributes.md#configure-syncing).

### Row filter

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](https://docs.databricks.com/aws/en/data-governance/unity-catalog/abac/policies.md).

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.

### Column mask

1. Create the masking UDF. This example masks a whole column.

   ```sql
   CREATE FUNCTION prod.governance.mask_value(val STRING)
   RETURNS STRING
   RETURN '****';
   ```

2. Tag the column and create the policy. Add the condition on the user's attribute to the policy's `WHEN` clause. The mask applies unless the user's `department` is `hr`:

   ```sql
   ALTER TABLE prod.hr.employees
     ALTER COLUMN home_address SET TAGS ('pii' = 'address');

   CREATE POLICY mask_addresses_outside_hr
   ON SCHEMA prod.hr
   COLUMN MASK prod.governance.mask_value
   TO `account users`
   FOR TABLES
   WHEN NOT has_identity_attribute_value('department', 'hr')
   MATCH COLUMNS has_tag_value('pii', 'address') AS address_col
   ON COLUMN address_col;
   ```

3. Test the policy. Query `prod.hr.employees`. If your `department` is `hr`, you see the home addresses. Otherwise, you see `****`.

## <a id="prevent-group-explosion" />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.

### <a id="row-filtering-example" />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);
```

### <a id="column-masking-example" />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;
```

## <a id="limitations" />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.

## <a id="additional-resources" />Additional resources

* [Identity attributes](https://docs.databricks.com/aws/en/admin/users-groups/identity-attributes/index.md)
* [`user_identity_attribute_values` function](https://docs.databricks.com/aws/en/sql/language-manual/functions/user_identity_attribute_values.md)
* [Core concepts for attribute-based access control (ABAC)](https://docs.databricks.com/aws/en/data-governance/unity-catalog/abac/core-concepts.md)
* [Common patterns for row filtering and column masking](https://docs.databricks.com/aws/en/data-governance/unity-catalog/abac/common-patterns.md)
* [Row filter and column mask policy evaluation and runtime behavior](https://docs.databricks.com/aws/en/data-governance/unity-catalog/abac/policy-evaluation.md)
* [Use mapping tables for dynamic access control](https://docs.databricks.com/aws/en/data-governance/unity-catalog/abac/mapping-tables.md)

- [Manage identity attributes with account SCIM](https://docs.databricks.com/aws/en/admin/users-groups/identity-attributes/provision-with-scim.md)
