Repository navigation
feat(authorization): enforce clearance, department and project labels in every chunk query - #20
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Background
Until now the compiled predicate carried only the tenant. This PR implements the rest of the decision table from
docs/architecture/authorization.md: clearance, department and project. It covers milestone items 2.1, 2.2 and 2.4 in one change, so that labels are never stored without being enforced.The predicate
NULL, which never compares true.policy_versionis nowabac/1.Labels
Migration
V5adds the label columns todocument_versionand to the queued job documents.classification_rankis a generated column, so the level order is defined in one place. Existing versions become public and unrestricted, which is how they behaved before.A label-only change does not call the model service. Revoking access therefore works during a model outage and applies to the next query.
Region and validity are scope, not authorization. They arrive with the scope filters in 2.3, after the time-semantics decision.
How it is verified
<=becomes<, when the department rule is dropped, or when array elements are left unquoted.jqwikis a new test dependency. The authorization rules require property-based tests, and jqwik provides generators and shrinking on the JUnit Platform the project already uses.Evaluation impact
None, as expected. The demo corpus has no access labels yet, so inside a tenant every principal still sees the same documents as before. The CI evaluation run of this PR (Linux x86_64, policy
abac/1) returns ranked results identical to the published M1b report in all 280 case and strategy pairs, with zero security violations. Labelled documents, the matching visibility labels and authorization-negative cases follow in the next PR. Only then does the evaluation security gate exercise these rules.背景
此前编译出的谓词里只有租户条件。本 PR 实现了
docs/architecture/authorization.md决策表的其余部分:密级、部门和项目。它把里程碑的 2.1、2.2、2.4 三项合在一次改动里完成,这样标签不会出现「已存储但未执行」的状态。谓词
SQL 的变化见英文部分的 diff。
NULL,比较永远不成立。policy_version现在是abac/1。标签
入库请求的字段和幂等规则见英文部分的代码块。
迁移脚本
V5给document_version和排队中的任务文档都加上了标签列。classification_rank是生成列,级别顺序只在一处定义。已有版本变为公开、不受限,和它们之前的行为一致。只改标签不会调用模型服务。因此模型服务宕机时仍然可以收回访问权限,并且对下一次查询生效。
region 和有效期属于适用范围,不属于授权。它们会在时间语义确定之后,随 2.3 的范围过滤一起加入。
如何验证
基于属性的测试的思路见英文部分的伪代码。
<=改成<、去掉部门规则、或者不给数组元素加引号,这个测试都会在几次尝试内失败。jqwik是新增的测试依赖。授权规则要求有基于属性的测试,而 jqwik 在项目已经使用的 JUnit Platform 上提供了生成器和收缩(shrinking)。对评测的影响
没有影响,这符合预期:demo 语料还没有访问标签,所以在同一个租户内,每个身份能看到的文档和之前一样。本 PR 的 CI 评测(Linux x86_64,policy
abac/1)与已发布的 M1b 报告相比,全部 280 个「用例 × 策略」组合的排序结果完全一致,越权结果为 0。带标签的文档、对应的可见性标注和授权负例会在下一个 PR 里加入,到那时评测的安全门禁才会真正检验这些规则。