diff options
| author | dev <dev@example> | 2026-11-13 22:28:22 +0000 |
|---|---|---|
| committer | dev <dev@example> | 2026-11-13 22:28:22 +0000 |
| commit | 50f296cf7609ce77d41b9fb3df51d6aeec8330d6 (patch) | |
| tree | a84e367145fa7f86f285b844144c55b3b3452cf3 /README | |
| parent | e12fc6e1c14afaab8711c6c9ac695ce911d83df5 (diff) | |
| download | access-control-50f296cf7609ce77d41b9fb3df51d6aeec8330d6.tar.gz access-control-50f296cf7609ce77d41b9fb3df51d6aeec8330d6.zip | |
Remove protected-refs: a rule covers what it names, and nothing else
`set protected-refs` raised the price of a listed ref by one level: write
needed force on main, force needed admin. It was a second, invisible list, and
it was the one part of the model that could not be read off the rules. The
question it was supposed to answer - "who can move main?" - stopped having an
answer in the file: you had to hold both the rules and the protection list in
your head and combine them, and the combination was where surprises lived.
Giving someone force so they could rewrite their own branches quietly let them
fast-forward main, because a fast-forward costs write, protection raised it to
force, and there it was.
Now a rule says what it says. An unscoped rule covers main; a rule that means
to leave main alone names what it covers instead, and the refusal says "bob
holds write on team, but not on refs/heads/main" rather than blaming a list
nobody remembered. Excluding one person from one branch is a matter of what
their lines name, which is the same mechanism as everything else here.
The setting is refused by name rather than ignored. A policy that still carries
one would otherwise mean "everyone with write can fast-forward main" while
looking like it said the opposite, and the operator would learn that from a push
rather than from the parser; so `set protected-refs` is now an error that says
what to write instead, and the suite asserts both halves - that it is refused,
and that cleaning it out makes the file valid again.
What stays: refs outside refs/heads and refs/tags still need admin whatever a
rule appears to grant about them. That one the policy genuinely cannot name in
advance, because it is the part of the namespace no policy was written with in
mind.
`protect` goes with it, so the editing commands are grant and revoke. The
example policy now names frank, whose two refs are main and the release tags,
because that is the shape the file is now meant to be written in.
Diffstat (limited to 'README')
| -rw-r--r-- | README | 38 |
1 files changed, 25 insertions, 13 deletions
@@ -23,11 +23,10 @@ Commands git-authz [--policy PATH] validate [options] git-authz [--policy PATH] grant <user> <repo> <level> [ref ...] git-authz [--policy PATH] revoke <user> <repo> - git-authz [--policy PATH] protect [--repo R] <ref pattern> ... `check` answers one question and is for humans and scripts. `authorize` is what git invokes. `validate` asks whether the host is wired to run the policy at all. -The last three edit the file. +The last two edit the file. Exit status is the interface, and it does not change: @@ -87,15 +86,24 @@ and works out what the update *is* before it asks who may do it: delete the branch HEAD points at admin a ref outside refs/heads, refs/tags admin -`set protected-refs <patterns>` raises the price of the listed refs by one level: -write needs force, force needs admin. `set protected-refs.<repo>` replaces that -list for one repository, so a repo with different customs does not inherit -somebody else's. +That is the whole of it. A rule says what it says: there is no second list +somewhere else in the file that can make one ref cost more than another, so the +answer to "who can move main" is the lines that name main, and nothing else. + +Which means an unscoped rule really does cover main: + + dave team admin # every ref in team, main included + +and a rule that means to leave main alone has to say so by naming what it covers +instead: + + bob team write refs/heads/feature/* # main is not named, so not granted Anything that is not a branch or a tag - `refs/notes`, `refs/merge-requests`, -whatever a tool invents next - is admin-only. It is the part of the namespace no -policy was written with in mind, and the safe reading of "not mentioned" is "not -granted". +whatever a tool invents next - is admin-only whatever a rule appears to grant +about it. That is the one price the program raises on its own, and it is the one +the policy cannot name in advance: it is the part of the namespace no policy was +written with in mind, and the safe reading of "not mentioned" is "not granted". Identity @@ -169,7 +177,6 @@ Editing the file git-authz grant bob team write refs/heads/feature/* git-authz revoke bob team - git-authz protect --repo team refs/heads/release Each writes the file atomically - a temporary in the same directory, then a rename, keeping the mode and owner - and preserves everything else in the file, @@ -200,8 +207,13 @@ Reading this as an operator Because the message ends with what it would have taken: - deny: bob has write on team refs/heads/main; it needs force - (raised from write: refs/heads/main is protected) + deny: bob holds write on team, but not on refs/heads/main; + that ref needs write + + or, when the ref is covered by a rule but costs more than it looks: + + deny: bob has write on team refs/notes/x; it needs admin + (neither a branch nor a tag) which is the whole design in one line: a refusal that names the level held, the ref, the level required and why, so the fix is obvious to the person who @@ -214,7 +226,7 @@ Tests make test `tests/unit.c` tests the policy engine directly - matching, normalisation, the -ladder, `@all`, protection, the sentences - and is the place where the semantics +ladder, `@all`, scope, the sentences - and is the place where the semantics are pinned. `tests/run.sh` drives the binary the way git does: an identity in the environment, `old new ref` lines on stdin, the repository as the working directory, the hook reached through its own name. It uses no git at all, so it |
