配置商业智能报表行级权限
根据用户访问规则设计身份映射与过滤代码,形成报表行级权限配置、越权检查和测试方案。
完整提示词
<context>
Row-level security in a BI tool is usually built once, tested by the author looking at their own view, and then leaks in ways nobody checked. Robust setups are dynamic: one rule driven by a mapping table of user identity to allowed values, kept up to date from an authoritative source, rather than one hard-coded role per region. Each tool has its own mechanics and its own bypasses. In Power BI, roles hold DAX filter expressions, dynamic rules compare USERPRINCIPALNAME() with the mapping table, filters flow along relationships from the one side to the many side (bi-directional flow needs the "apply security filter in both directions" setting), users must be added to the role in the service, and the rules apply only to people who consume the content (workspace Viewers, app users, people the report or semantic model is shared with): workspace Admins, Members and Contributors see all rows. In Tableau, rules are user filters or, better, an entitlement table joined to the data with a data source filter using USERNAME() or ISMEMBEROF(); people who can edit or download the data source may bypass a filter set only in a workbook. In Looker, access_filter on an explore ties a field to a user attribute, and access grants restrict fields. Hierarchies (a director sees all regions below them), users in several groups, and users missing from the mapping need explicit rules; the safe default is that an unmapped user sees nothing. Testing means viewing as specific users, not as the author.
</context>
<task>
Tool: {{tool}}
<access_rules>
{{access_rules}}
</access_rules>
{{#model}}
<model>
{{model}}
</model>
{{/model}}
1. Restate the access rules as a security model: user groups, the column or columns that restrict rows, hierarchy rules, people who see everything, and the default for unmapped users (see nothing).
2. Design the mapping table: columns (user identity in the format the tool sees, allowed value, scope level), source of truth, refresh, and owner. For hierarchies, describe how they are expanded (one row per allowed value, or a path column).
3. Write the implementation for the named tool: the role or filter definitions with code (DAX filter, Tableau calculated field and data source filter, or LookML access_filter and user attribute), where the mapping table joins the model, and how filters propagate to related tables.
4. Close the tool's known bypasses: workspace or project permissions, data source download or edit rights, exports, subscriptions and embedded use. Say which ones apply and what to check in the tool's settings.
5. Write a test matrix: for each test user type, the filter state, the rows and totals expected, and the result, including a user in two regions, a hierarchy user, an unmapped user, and a user who is removed from the mapping.
6. List gaps and risks, including whether column-level restrictions are also needed (for example salary columns) and how they would be handled in this tool.
7. Define maintenance: who updates the mapping, how joiners, movers and leavers are handled, and a periodic access review.
</task>
<constraints>
- Write code only for the tool named; mark tool features or settings whose names or availability depend on edition or version as "check in your version".
- Never treat a hidden page, hidden column or report-level filter as security.
- Default to deny: no rule should give an unmapped user all rows.
- Do not use real user identities in examples; use placeholders.
- Testing must be done as the viewer, not the author; say so explicitly.
</constraints>
<output_format>
## Security model
Table: group | sees | rule.
## Mapping table
Table: column | meaning | example placeholder value. Then source, refresh and owner.
## Implementation
Steps with code blocks.
## Test cases
Table: test user | filters | expected rows or totals | result.
## Gaps and risks
## Maintenance
</output_format>可替换内容
- {{tool}}
- {{access_rules}}
- {{#model}}
- {{model}}
- {{/model}}
分类与标签
编程开发、行级安全、报表权限、身份映射、权限测试