summaryrefslogtreecommitdiffstats
path: root/authz.conf
diff options
context:
space:
mode:
authordev <dev@example>2026-11-13 20:34:47 +0000
committerdev <dev@example>2026-11-13 20:34:47 +0000
commit19a3eb704479fa01c383960ca21a057e8c5fbaf7 (patch)
tree565882a47da5ced0f2112a36703a81406f9a0a69 /authz.conf
parente755a181b0e4c952c35d80e2aa1acd584d2e4595 (diff)
downloadaccess-control-19a3eb704479fa01c383960ca21a057e8c5fbaf7.tar.gz
access-control-19a3eb704479fa01c383960ca21a057e8c5fbaf7.zip
Install: the hook is a relative symlink, and the policy is configuration
The hook is a symlink named pre-receive, because that name is what core.hooksPath looks for and what selects authorize mode inside the binary. It was built by cd'ing into the hook directory first, which left the awk script writing the relative path out of reach, and the recipe failed with the link never created. The path is computed where the script is, and the link is made from there. Relative rather than absolute for the reason that matters during an install: a staged tree under DESTDIR, an unpacked prefix, or an image assembled somewhere else must point at the binary that came with them, not at whatever lives at the same absolute path on the machine reading the link. relpath.awk walks both paths component by component - it is not a string-prefix operation, because /usr/local/share and /usr/local/bin share a prefix only up to the point where ".." starts - and falls back to the absolute path when a component cannot be named from where it stands. authz.conf is the example policy, and the installer treats it as configuration: an existing file is an operator's, so it is kept and the new example lands beside it as authz.conf.new rather than over the rules someone wrote down. `make sanitizer' builds both suites under AddressSanitizer and UBSan, which is how the editing bugs in the previous commit were found.
Diffstat (limited to 'authz.conf')
-rw-r--r--authz.conf46
1 files changed, 46 insertions, 0 deletions
diff --git a/authz.conf b/authz.conf
new file mode 100644
index 0000000..afea7d2
--- /dev/null
+++ b/authz.conf
@@ -0,0 +1,46 @@
+# git-host access policy.
+#
+# One file, read by the receive hook on every push and by nothing that serves
+# reads. The deployed copy is mounted read-only - a ConfigMap - so changes are
+# made to the copy in git and rolled out; `git-authz grant`, `revoke` and
+# `protect` edit a source copy and refuse, with an explanation, when pointed at
+# the read-only one.
+#
+# <user> <repo> <write|force|admin> [ <ref pattern> ... ]
+#
+# Levels stack: admin implies force implies write, and every rule for a user
+# counts, so the strongest match wins. There is no 'deny': access is taken
+# away by deleting the rule that gave it.
+#
+# A ref pattern is a glob in which '*' crosses '/'. "main", "heads/main" and
+# "refs/heads/main" name the same branch; a bare name is always a branch, so a
+# tag has to be written "refs/tags/v1" or "tags/v1". With no patterns at all
+# the rule covers the whole repository, refs included.
+#
+# '@all' means everyone this policy already names somewhere. It is not a
+# wildcard for anonymous users: nobody reaches it who has no rule of their own.
+
+# What costs an extra level to move. A write on these needs force, a force
+# needs admin, and refs outside refs/heads and refs/tags need admin regardless.
+set protected-refs refs/heads/main refs/tags/*
+
+# The account for break-glass and for the refs nobody else should touch: it is
+# unscoped, so it covers the whole repository including refs/notes and friends.
+alice * admin
+
+# Default for everyone the policy knows: their own branches, anywhere. Reads
+# are open, so this is about writing, and there is no rule here to be the
+# fall-through for someone the policy has never mentioned.
+@all * write refs/heads/*
+
+# Contributor on team: feature branches only.
+bob team write refs/heads/feature/*
+
+# Senior on team: may rewrite his feature branches and delete them.
+carol team force refs/heads/feature/*
+
+# Maintainer of team: everything, including main, tags, and deletions.
+dave team admin
+
+# Team A's repository, with an unrelated ACL.
+erin secrets admin