> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cube.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Row-level security

> Covers applying group- and attribute-based filters so query results only include rows users are allowed to see.

The data model serves as a facade of your data. With row-level security,
you can define whether some [data model][ref-data-modeling-concepts] facts are exposed
to end users and can be queried via [APIs & integrations][ref-apis].

Row-level security in Cube is similar to row-level security in SQL databases.
Defining whether users have access to specific facts from [cubes][ref-cubes] and
[views][ref-views] is similar to defining access to rows in database tables.

**By default, all rows are *public*,** meaning that no filtering is applied to
data model facts when they are accessed by any users.

## Managing row-level access

You can use [access policies][ref-dap] to manage both [member-level][ref-mls]
and row-level security based on groups and [user attributes][ref-security-context].

Here's an example of how to filter rows by a user attribute using access policies:

```yaml title="YAML" theme={"dark"}
cubes:
  - name: orders
    # ...

    access_policy:
      - group: manager
        row_level:
          filters:
            - member: country
              operator: equals
              values: [ "{ userAttributes.country }" ]
```

```javascript title="JavaScript" theme={"dark"}
cube(`orders`, {
  // ...

  access_policy: [
    {
      group: `manager`,
      row_level: {
        filters: [
          {
            member: `country`,
            operator: `equals`,
            values: [ userAttributes.country ]
          }
        ]
      }
    }
  ]
})
```

[ref-data-modeling-concepts]: https://docs.cube.dev/docs/data-modeling/overview.md

[ref-apis]: https://docs.cube.dev/reference

[ref-cubes]: https://docs.cube.dev/docs/data-modeling/cubes

[ref-views]: https://docs.cube.dev/docs/data-modeling/views

[ref-cubes-sql]: https://docs.cube.dev/reference/data-modeling/cube.md#sql

[ref-dynamic-data-modeling]: https://docs.cube.dev/docs/data-modeling/dynamic

[ref-dap]: https://docs.cube.dev/docs/data-modeling/data-access-policies.md

[ref-mls]: https://docs.cube.dev/docs/data-modeling/access-control/member-level-security.md

[ref-security-context]: https://docs.cube.dev/docs/data-modeling/access-control/context.md


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.