Ir para o conteúdo

Lição 21 · Sharing, Governance and Performance

Row-Level and Column-Level Security

Protect data in Sigma with row-level security using user attributes, teams or email, add column-level security in data models, and test rules properly.

Sharing a workbook decides who can open it. Data security decides what they can see inside it. A manager of the North region and a manager of the South region might open the same dashboard and see different rows. This lesson explains the ideas. Work with your data and security teams before you protect real data.

Layers of protection

  1. Platform permissions: what the data platform allows for the identity that queries it. With OAuth connections, Sigma's documentation says existing platform row rules are respected.
  2. Sigma connection and data permissions: who can use which connections and sources.
  3. Row-level and column-level rules in Sigma.
  4. Document sharing: who can open workbooks and models.

Rules close to the data protect more tools than rules that exist in one workbook.

Row-level security (RLS)

Sigma's documentation describes a two-step method: create a column that holds the rule, then filter the element to keep only rows where it is True. Hide the rule column so users do not see it.

The recommended method uses user attributes: values that administrators assign to users or teams.

TEXT
CurrentUserAttributeText("Region") = [Store Region]

Other documented methods use teams or email:

TEXT
CurrentUserInTeam([Team Name Column])
[Salesperson Email] = CurrentUserEmail()

You can combine conditions, for example so that managers see everything:

TEXT
[Salesperson Email] = CurrentUserEmail()
  or CurrentUserInTeam("Sales Manager")

The attribute's value must match the column's data type. Sigma's documentation also says that CurrentUserAttributeText returns an empty string when a user has no value and no default. A row whose rule column is also an empty string could then match, so check your data for blank values.

Rules that stay safe

  • Apply the RLS filter directly on the element, not through a control, because a control value can be changed downstream.
  • Put rules in a data model where your team wants workbooks to build on protected data, and verify with a test that new workbooks are restricted.
  • For custom SQL, the documentation shows a pattern that inserts a system function into the query with {{#formula ...}}.
  • For embedded analytics, enforce the rules with embed URL parameters or JSON Web Token claims.
Python Stand-in: a rule that fails closed

Press Run (or Ctrl + Enter) to see the result here.

Program input · what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The new user sees nothing rather than everything. Test what your real rules do for users with no attribute value, and for rows with a null region.

Column-level security (CLS)

CLS restricts which columns someone can see. In a data model, you choose restricted columns and set who may view them: no one, specific users and teams, or users with an assigned attribute value. Publish the model to enforce the rule.

According to Sigma's documentation:

  • Users without access cannot select the column from the data model. In workbooks it appears as a restricted column with a "No access" value.
  • If several rules apply to the same user and column, they combine as a union: any rule that grants access is enough.
  • Lookups, metrics and calculated columns that use restricted columns inherit the rules.
  • Columns read through sigma_element() in SQL or sigma.get_element() in Python do not inherit CLS, so you must add the rule to that output.

The last point is important. Anyone building SQL or Python elements on restricted data must think about it.

Aggregates can leak

Even when a user cannot see individual salaries, an average for a team of one person reveals that salary. A "small group" rule hides aggregates computed from too few people.

SQL Stand-in: suppress small groups

Press Run (or Ctrl + Enter) to see the result here.

The threshold of five is only an example. Your policy decides the real rule, and clever filtering can still leak information, so treat sensitive data with care and involve your privacy team.

Test your rules

Test Expect
User with one region Only that region
User with no attribute Nothing
Manager All rows allowed by policy
Totals and charts Same restrictions as tables
Exports and schedules No extra rows
Embedded view Rules enforced by token or parameters
New workbook on the model Rules still apply

Use real test accounts or a supported preview-as-user feature. Write down the results and repeat the tests after model changes.

Service accounts and caching

If queries run as a shared service account, results reflect that account's permissions. Sigma's caching documentation warns that results cached from service account queries can fail to match individual users' OAuth permissions. Ask your admin how identity works before you rely on platform-side rules.

Common mistake: testing security only with your own admin account. Admins often see everything. Always test with the least privileged real role.

Writing the policy first

Write the rule in plain words before you write any formula: who may see which rows and which columns, who approves access, and what happens when someone changes teams or leaves. A sentence such as "sales managers see their own region, and the finance team sees all regions" can be reviewed by people who never read formulas.

Then decide who maintains user attributes and team membership. A correct formula with outdated assignments still shows the wrong people the wrong data. Schedule a regular access review, and keep a record of your test results.

When a rule changes

Treat a change to a security rule like a release. Test it in a safe copy where you can, repeat the whole test table, and have a second person review the formula and the results. Keep a note of what changed, who approved it and when. If you discover that people saw data they should not have seen, tell your security or privacy team promptly instead of only fixing the formula.

Check your understanding

Quick check · 4 questions

of 4 answered You scored / 4 · perfect!

  1. 1. What does Sigma's documented RLS method do after creating the rule column?

    The element is filtered on the rule column, which is then hidden.
  2. 2. Why not put the security rule in a control?

    The documentation says to filter directly on the element.
  3. 3. If two column rules apply to one user, how do they combine?

    The documented behavior is a union of rules.
  4. 4. Which reference does not inherit column-level security?

    The documentation lists SQL and Python element references as exceptions.

Summary

  • Combine platform, connection, row, column and sharing protections.
  • RLS filters on a rule built from user attributes, teams or email.
  • CLS restricts columns in data models, with SQL and Python exceptions.
  • Design rules to fail closed and watch for small-group leaks.
  • Test as a real low-privilege user.

Next: Performance, Caching and Materialization

Seu progresso fica salvo neste navegador. Não precisa de conta.