Restrict a table
Keep a principal, or a kind of principal, away from a table that a broad grant would otherwise reach.
Restrict a table
Pick the narrowest tool that covers who must be kept out:
| Who | Use | Applies to |
|---|---|---|
| One principal or group | An exception on their grant | That grant only |
| Everyone holding a role | A deny in the custom role (create a custom role) | Every grant of the role |
| Every principal of a kind, or every request matching a condition | A forbid policy (conditions and policies) | The whole account, over any grant |
An exception or a role's deny narrows only the grants it is part of: a principal who reaches the table through another grant, directly or through a group, still has that grant's access. Use Explain access to find every grant that allows it, or a forbid policy to block it whatever the grants.
Denying table.read on a table keeps a query from reading it, including through its columns. Deny table.write to stop
ingestion into it.
Steps: exception on one grant
- Open Settings → Account → Access, or the user's page under Settings → Account → Users.
- On the grant that reaches the table, select Edit condition and exceptions.
- Open Advanced: exceptions and select Add deny.
- Under Denied permissions, choose the table permissions to remove, such as
table.read. - Under Condition, name the tables:
resource.Name == "payroll", orresource.Name in ["payroll", "salaries"]. - Select Save.
A grant holds at most 16 exceptions. An exception can only remove permissions the role grants.
Example: keep a service account out of hr.* tables
A service account holds Data reader on the account for an alert.
- Open Settings → Account → Service accounts, select it, and under Roles held select Edit condition and exceptions on its Data reader grant.
- Add deny: Denied permissions
table.read, Conditionresource.Name.startsWith("hr."). - Save, then confirm with Explain access: subject the service account, Resource type Table, table
hr.salaries, Permissiontable.read. The result is Denied, naming the deny on the grant.
To keep every service account out instead, create a forbid policy: Permissions table.read, Applies to
principals Service account, Scope Table, Condition resource.Name.startsWith("hr.").
Tables restricted with the older per-user schema permissions show under Legacy restrictions on the table's access panel and the user's page, where they can be edited or removed (legacy table restrictions). Such a restriction narrows every grant its user holds in the account, deployment-wide grants such as Administrator included. It names one user; it cannot be placed on a group.