Repository navigation
docs(authz-playground): show the conditions fix and the boundary-hour fix #18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,9 +20,9 @@ So I gave four of them the same rules and ran every possible request through all | |
| - **Live demo:** [https://0-draft.github.io/authz-playground/](https://0-draft.github.io/authz-playground/) | ||
| - **Repo:** [0-draft/authz-playground](https://github.com/0-draft/authz-playground) | ||
|
|
||
|  | ||
|  | ||
|
|
||
| One square is one request, one row per engine, filled means allowed. Pink is where they disagree. | ||
| One question, asked of every engine at every hour of the day. A raised line is allow. Red is where they disagree. | ||
|
|
||
| ## Where ReBAC stops | ||
|
|
||
|
|
@@ -32,26 +32,35 @@ That third one is where ReBAC stops keeping up. `check(user, relation, object)` | |
|
|
||
| That gap is why OpenFGA later added Conditions. Their announcement names time of day as the example relationships handle badly. | ||
|
|
||
| The same rules side by side are worth as much as the decisions: | ||
| The playground now has that fix as a fifth row: the same Zanzibar model with an OpenFGA condition. The grant stays relational, and one more relation gates it: | ||
|
|
||
|  | ||
| ```text | ||
| define within_hours: [user:* with business_hours] | ||
| define editor: (owner or admin from parent) and within_hours | ||
| ``` | ||
|
|
||
| It agrees with the other three on every request. It is still not free. A condition can only hang off a tuple, and business hours are about the request rather than any relationship, so every document needs a placeholder tuple whose only job is to carry the clock. The page rates it possible but forced, not native. | ||
|
|
||
|  | ||
|
|
||
| Add a document and Casbin needs its policy table regenerated, while ReBAC just gains a tuple and the model never moves. | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This sentence compared the four engines' policy shapes and leaned on the |
||
|
|
||
| ## What broke | ||
|
|
||
| The projections are where I could lie without noticing, so they get checked twice: all four engines run every request and any disagreement is reported, and a separate implementation written from the requirement text alone checks they are not all wrong together. | ||
| The projections are where I could lie without noticing, so they get checked twice: every engine runs every request and any disagreement is reported, and a separate implementation written from the requirement text alone checks they are not all wrong together. | ||
|
|
||
| Both earned their keep. | ||
|
|
||
| I gave the ReBAC model `viewer: owner or editor`, because obviously an editor can read too. The requirements never said that. Disagreements doubled and the comparison was quietly dishonest until the harness flagged it. | ||
|
|
||
| Worse, the request enumeration sampled 03:00, 10:00, 14:00 and 22:00, so neither edge of the business-hours window was ever evaluated. I moved one engine's window to 08:00-19:00 to see what would happen. All fourteen tests passed. The suite that existed to protect the comparison could not see the one boundary the whole thing rests on. | ||
|
|
||
| The fix was to sample both edges of the window and the hour either side of them, 08, 09, 17 and 18, plus a test that fails if any of those ever drops out of the enumeration. The 08:00-19:00 window now fails at once. | ||
|
|
||
| ## How it runs | ||
|
|
||
| No backend. Cedar through its official wasm bindings, Casbin's TypeScript build, and about a hundred lines reimplementing the Zanzibar check algorithm. Rego is OPA itself compiled to `js/wasm`, so policies are compiled and evaluated live: 8 MB gzipped, loaded lazily, roughly 2 ms per evaluation after the first. | ||
|
|
||
| If you try that last one, restrict the builtins. I shipped the default set, which left `http.send` reachable from pasted Rego. It fired a request from the visitor's browser and deadlocked the Go runtime for the rest of the session. | ||
|
|
||
| Have a go at stage 3 and drag the hour slider: [0-draft.github.io/authz-playground](https://0-draft.github.io/authz-playground/) | ||
| Have a go at stage 3 and drag across the chart: [0-draft.github.io/authz-playground](https://0-draft.github.io/authz-playground/) | ||
Uh oh!
There was an error while loading. Please reload this page.