A host named in FORGE_ORIGIN_ALLOW can be mirrored as well as connected: its origin's git trusts it by name, as FORGE_OUTBOUND_TRUSTED_HOSTS does #73
No reviewers
Labels
No labels
agent-work
agent-working
ultracode
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
trevato-apps/forge!73
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "tdobbertin-espo/forge:fix/origin-allow-mirrors"
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?
FORGE_ORIGIN_ALLOWis how an operator vouches for a forge inside the network: README calls it the hosts "an operator vouches for on a LAN", and discovery lets such a host through. But the mirror's git never read it: outbound git trusts onlyFORGE_OUTBOUND_TRUSTED_HOSTSand the admin's list (0d7ce61a). So a host named only inFORGE_ORIGIN_ALLOWconnects, and its live browse, issues and write-through work (the API client does not vet the host), and then every mirror, sync, fetch and push-through from it fails with "refused: the remote's host is a private address". Nothing on the way says which setting is missing.Now a host name in
FORGE_ORIGIN_ALLOWis trusted for its origin's git as an admin-trusted host is.vettedEnv(src/origins/git-mirror.ts) adds the clone URL's host to the trusted names when the operator allows that URL'shost:port, or its bare hostname for every port. The match isoperatorAllowed(src/origins/discover.ts), which discovery now uses too, so the two read the setting one way.What is unchanged:
FORGE_ORIGIN_ALLOWstill reaches discovery only, as the trusted list refuses an address. A trusted name has no further limit on where it resolves, and neither has this one.host:portcovers that port only. Another name at the same address is refused.FORGE_ORIGIN_ALLOW. The origin row does not say "trusted internal host" for it.FORGE_ORIGIN_ALLOWunset, nothing changes.Why this, and not a refusal at Connect
The other fix is to refuse such a host at Connect, with a sentence that names
FORGE_OUTBOUND_TRUSTED_HOSTS. That would take away what works today for every operator who setFORGE_ORIGIN_ALLOW(live browse, issues and write-through go through the API, which never vetted the host). It would also ask them to write each host twice, in two variables that mean "I vouch for this host". This change givesFORGE_ORIGIN_ALLOWthe meaning README already states, and it reuses the rule0d7ce61achose, so there is no second rule to keep in step.Tests
bun 1.3.13, a scrubbed environment (no agent variables):
test/origin-allow-mirror.test.ts(new): 5 pass, 0 fail here. Onmain9900e4bathe same file gives 2 pass, 3 fail: the vet of an allowed name, thehost:porttest and the end-to-end mirror all get "refused: the remote's host is a private address". The two that pass onmainare the refusals, which this change keeps. The end-to-end half ran here (this machine has a private address); it skips, and says so, where there is none.bun test --timeout 60000call: 370 pass, 0 fail across 23 files.test/upstream_follow.test.tsalone: 29 pass, 0 fail.bun scripts/gate.tsandtsc --noEmit: clean.Seen on the way, not changed here: in one process,
test/upstream_follow.test.ts'safterAllleaves the mirror's outbound at{}(no loopback allowance), so a mirror test after it is refused. Onmain,upstream_followthenoriginsgives 3 failures, and the set above withupstream_followin it gives 5 (inoriginsandweb-origins), the same on this branch. Each passes alone.the 23 files
origin-allow-mirror, trusted-hosts, trusted-hosts-ui, origins, origins-oauth, origins-security-provider, origins-sync, web-origins, mirror-outbound, mirror-out, push-through, migrate, oauth-discovery, mcp-discovery-walk, report-discovery, upstream-follow-web, follow-e2e, following, and the five cross files reserved-names, studio, shards, check-list, hollow (each
test/<name>.test.ts).🤖 Generated with Claude Code
View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.