Remove the repo allowlist from the Forgejo admin broker config #64
Labels
No labels
Agent
Ignore
Agent
In Progress
Agent
Planned
Agent
Planning
Agent
Ready
Agent
Triage
Compat
Breaking
Kind
Bug
Kind
Documentation
Kind
Enhancement
Kind
Feature
Kind
Security
Kind
Testing
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Reviewed
Confirmed
Reviewed
Duplicate
Reviewed
Invalid
Reviewed
Won't Fix
Status
Abandoned
Status
Blocked
Status
Need More Info
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
lucas/omp-deck#64
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Implementation: #65
Problem
The Forgejo admin broker (
apps/broker, added in #55 / PR #56) only answersPOST /permissionfor repositories listed in its config'sreposallowlist. Any other repository gets403 repository not allowed, which fails the trigger. The allowlist does nothing useful:It only adds another thing to configure for every repository. It was never a deliberate requirement. It came from an early design idea about future mutating admin actions, and the broker only does a read-only permission lookup.
Remove it. After this change the broker config is
{forgejoUrl, adminToken, webhookSecret}, and/permissionanswers for anyowner/name. Existing config files may still containrepos, and so may the unfilled templates the entrypoint wrote earlier. The broker ignores that key silently: no log line, no error. The operator can delete it whenever they like.Plan
1. Broker config: drop
reposIn
apps/broker/src/config.ts:reposfield and its doc comment fromBrokerConfig.parseConfig, remove thereposvalidation and removereposfrom the returned object. Unknown keys, includingrepos, are not read at all. That is how a leftoverreposgets ignored.isTemplatetoo.forgejoUrl === "" && o.adminToken === "". Drop thereposcondition so that both old templates (with"repos": []) and new ones (without it) count as unconfigured.loadConfigdoc comment, change "(emptyforgejoUrlandadminToken, norepos)" to "(emptyforgejoUrlandadminToken)".2. Broker
/permission: answer for every repositoryIn
apps/broker/src/server.tscreateHandler:const repos = new Set(cfg?.repos);.if (!repos.has(repo.toLowerCase())) { … 403 … }block.503 broker not configuredwhencfg === null, thenfetchPermissionImpl, which returns 502 on failure or 200{level}.3. Tests
apps/broker/src/config.test.ts:reposfromVALIDand from the expected object in "normalises a valid config".[{ repos: ["nope"] }, "repos"]row.repos: [](it must still returnnull), and also assert that{ forgejoUrl: "", adminToken: "", webhookSecret: "a".repeat(64) }withoutreposreturnsnull.{ ...VALID, repos: ["nope"] }loads, and the result equals the config withoutrepos.apps/broker/src/server.test.ts:reposfromCFG.{ repo: "other/x", user: "alice" }. Expect 200 with the stubbed level, and expect the stub to have been called with ownerotherand namex. Assert the call in the same shape the existing test uses fors.calls.apps/broker/src/forgejo.test.ts: removerepos: []fromcfg.4. Container entrypoint and deck client
docker/entrypoint.sh:"repos": []line from the template heredoc, and the comma that ends thewebhookSecretline before it, so the JSON stays valid.apps/server/src/forgejo/broker-client.tscheckPermission: change the doc comment to/** \user`'s permission on `repo` (`owner/name`). */`.5. Docs
docs/deployment.mdbroker section:"repos": ["owner/name"]from the format example, and the comma afterwebhookSecret.reposis the allowlist the broker answers permission checks for."docs/configuration.md:reposallowlist fails the trigger."After these edits,
grep -rniE "allowlist|\\brepos\\b" apps/broker docker docs/deployment.md docs/configuration.md apps/server/src/forgejo/broker-client.tsmust not return any broker-allowlist hits. Hits for Forgejo API paths like/repos/…are expected.Verification
bun run typecheckpasses for all workspaces.cd apps/broker && bun testpasses, including the new cases: a leftoverreposis ignored, a template withoutreposis unconfigured, and/permissionforother/xreturns 200.cd apps/server && bun testpasses (the deck side is unchanged apart from a comment).sh -n docker/entrypoint.shpasses. Extract the template heredoc and run it throughjq .to confirm it is valid JSON."repos": ["a/b"]. It starts.curl --unix-socket <sock> -X POST http://x/permission -d '{"repo":"other/x","user":"alice"}'no longer returns403 repository not allowed: with no reachable Forgejo it returns 502, and with one it returns 200{level}.