Access control
Seeing the policy: a diagram generated from the file
On this page
Introduction
An access policy is a file, which makes it exact and testable. A reviewer reading a pull request still wants to see the shape of the rules at a glance.
Signari draws the policy as a diagram, from the same parsed structure the engine evaluates. So the picture cannot drift from what the policy does.
You draw it with signari policy graph, from the same file you test and apply.
Draw a policy
This command draws a policy file as an SVG (Scalable Vector Graphics) image:
Shellsignari policy graph -policy-file policy.yaml -out policy.svg
It writes the image, and says what it drew:
Textwrote policy.svg 5 rule(s) -- 4 restricting, 1 denying 7 test(s), all passing (a file whose tests fail does not load)
The diagram for an example policy looks like this:
Why the diagram is drawn from the file
Access policy explains why Signari's rules are a file rather than a graph drawn on a canvas. The diagram follows from that: the file comes first, and the picture is drawn from it.
The picture cannot differ from the behaviour, because it is rendered from the same parsed structure the engine evaluates. It is not a second copy of the rules that could fall out of step with the first.
The cost is that you cannot assemble a policy by dragging boxes. You write nine lines of YAML and its tests.
Why nothing in the diagram points at anything
The layout shows how the rules apply. Arrows would mean the rules run in sequence, and they do not.
A request names one application. What applies is the universal rules plus that application's rules, together, not in order.
So the universal rules are a band across the top, the applications sit in a grid beneath, and nothing points at anything.
A condition that is enforced and not drawn
If a condition were enforced but not drawn, a reviewer could read the diagram, see no device requirement, and not work out why a sign-in is refused.
TestEveryConditionIsDrawn walks the Conditions struct by reflection, and sets
each field alone. It fails when one draws nothing, with a message like this:
TextConditions.DeviceCompliant is enforced and draws nothing. Somebody reads thediagram, sees no such requirement, and cannot work out why their login isrefused.
It also fails if the test itself leaves a new field unset. Otherwise, adding a field would make the test pass while proving nothing about it.
The test checks that each condition changes the output, not what the output says. So the wording can be improved without breaking it.
Deterministic, and no JavaScript
The diagram is plain SVG, laid out in Go. Two runs over the same file are byte-identical, so the diagram can be committed and its diff read. Applications are sorted for the same reason.
It renders in a browser, in a README, in a pull request comment, and in any terminal that can show an image. Nothing is fetched, and nothing executes.
Rule names are text an administrator supplies, going into markup, so they are
escaped. A test checks this with a rule named break <svg> & "quotes".
Text that fits
Truncation is measured against the pixel width available, rather than a fixed
character count. So a long name such as contractors-cannot-reach-payroll, the
name that says what the rule does, is cut only where its card runs out of room.
Drawn only for a file that would load
policy graph parses the file rather than reading it, and parsing runs the
file's own tests. A policy whose tests fail cannot be drawn.
So a reviewer never sees a diagram of a policy that could not be deployed.
Not in the console
The diagram is not in the console for now. The command line writes a file you commit, attach to a pull request, or paste into a review, which is where a policy change is discussed.
A console page showing the live policy would be a different job. It would need to say which version is loaded and when, or it could disagree with production without anyone noticing.
Changed Signari v0.2