Carry GitHub contributions onto the forge, and open the front door #1074

Merged
jaylouisw merged 1 commit from feat/gh-bridge into main 2026-11-08 15:15:33 +00:00
Owner

Three faces of one problem: nobody could read this repository, and nothing a contributor sent
could reach it.

1. The front door

git.jayw.uk was behind a wildcard Cloudflare Access application, so a stranger met a login page and
the GitHub mirror became the de-facto front door. The instance is now publicly readable:

/ 200
/explore/repos 200
/jaylouisw/packetforge/issues 200
/api/v1/repos/jaylouisw/packetforge 200
anonymous git clone 1,858 files
anonymous POST an issue refused
/settings redirects to login

Access is one application — git.jayw.uk → bypass — and *.jayw.uk still covers every other
host on the domain. A path-scoped variant was tried first and removed: it made browsing work but left
git clone dead, because Forgejo clones through /packetforge.git, a different path prefix.

2. The credential shape

scripts/cf-access-bypass.js now takes either a scoped token (Bearer header) or the account Global
API Key (X-Auth-Email + X-Auth-Key). Sending one as the other returns 9103 Unknown X-Auth-Key or X-Auth-Email, which reads like a bad key when it is a bad header.
test/cf-access-bypass-auth.test.js pins the mapping, including that the account-wide key is never
used when a narrow token exists.

3. The bridge

scripts/gh-bridge.js:

  • --issues — GitHub issues become Forgejo issues, credited to the author, labelled from-github.
  • --prs — each GitHub pull request becomes a gh/<n> branch, fetched from refs/pull/<n>/head so
    fork PRs work too, pushed verbatim, plus a Forgejo pull request so CI runs here.
  • --report — merges are reported back on the GitHub thread.

Every imported object carries a <!-- gh-issue: N --> / <!-- gh-pr: N --> marker, and the script
finds its own work by reading that marker back. That is what makes re-running safe.

Proven on two real contributions: GitHub #1442 → forge #1069 and #1438 → #1070, branches gh/1442
and gh/1438 pushed with their commits intact, and CI picked both up.

Two defects the live run caught, both fixed

  • The comment posted onto public GitHub threads carried the internal API address instead of the
    published hostname. Now PF_PUBLIC_URL is separate from the API URL, and the two live comments are
    corrected.
  • It promised replies would be carried back and forth. Only new issues and pull requests cross, so the
    text now says a maintainer will reply on the thread — no promise the bridge cannot keep.

Guard

The canonical-URL check flagged this work, correctly: scripts/gh-bridge.js and CONTRIBUTING.md
must name GitHub. Both are reasoned entries in canonical.ALLOW, so the exception is visible rather
than silenced.

103 suites, 4,963 assertions, all passing.

Closes #1073.

Three faces of one problem: nobody could read this repository, and nothing a contributor sent could reach it. ## 1. The front door `git.jayw.uk` was behind a wildcard Cloudflare Access application, so a stranger met a login page and the GitHub mirror became the de-facto front door. The instance is now publicly readable: | | | |---|---| | `/` | 200 | | `/explore/repos` | 200 | | `/jaylouisw/packetforge/issues` | 200 | | `/api/v1/repos/jaylouisw/packetforge` | 200 | | anonymous `git clone` | 1,858 files | | anonymous `POST` an issue | refused | | `/settings` | redirects to login | Access is **one** application — `git.jayw.uk` → bypass — and `*.jayw.uk` still covers every other host on the domain. A path-scoped variant was tried first and removed: it made browsing work but left `git clone` dead, because Forgejo clones through `/packetforge.git`, a different path prefix. ## 2. The credential shape `scripts/cf-access-bypass.js` now takes either a scoped token (Bearer header) or the account Global API Key (X-Auth-Email + X-Auth-Key). Sending one as the other returns `9103 Unknown X-Auth-Key or X-Auth-Email`, which reads like a bad key when it is a bad header. `test/cf-access-bypass-auth.test.js` pins the mapping, including that the account-wide key is never used when a narrow token exists. ## 3. The bridge `scripts/gh-bridge.js`: - `--issues` — GitHub issues become Forgejo issues, credited to the author, labelled `from-github`. - `--prs` — each GitHub pull request becomes a `gh/<n>` branch, fetched from `refs/pull/<n>/head` so fork PRs work too, pushed verbatim, plus a Forgejo pull request so **CI runs here**. - `--report` — merges are reported back on the GitHub thread. Every imported object carries a `<!-- gh-issue: N -->` / `<!-- gh-pr: N -->` marker, and the script finds its own work by reading that marker back. That is what makes re-running safe. Proven on two real contributions: GitHub #1442 → forge #1069 and #1438 → #1070, branches `gh/1442` and `gh/1438` pushed with their commits intact, and CI picked both up. ## Two defects the live run caught, both fixed - The comment posted onto public GitHub threads carried the **internal** API address instead of the published hostname. Now `PF_PUBLIC_URL` is separate from the API URL, and the two live comments are corrected. - It promised replies would be carried back and forth. Only new issues and pull requests cross, so the text now says a maintainer will reply on the thread — no promise the bridge cannot keep. ## Guard The canonical-URL check flagged this work, correctly: `scripts/gh-bridge.js` and `CONTRIBUTING.md` must name GitHub. Both are reasoned entries in `canonical.ALLOW`, so the exception is visible rather than silenced. **103 suites, 4,963 assertions, all passing.** Closes #1073.
Carry GitHub contributions onto the forge, and open the front door
Some checks failed
CI / Test (Node 18) (pull_request) Failing after 1m26s
CI / Test (Node 20) (pull_request) Failing after 1m19s
CI / Server smoke test (pull_request) Successful in 30s
CI / Docker build (pull_request) Successful in 11s
CI / Test (Node 22) (pull_request) Failing after 1m19s
5d1d46130e
The project lives on its own forge, but strangers could not read it: git.jayw.uk sat
behind a wildcard Cloudflare Access application, so the first thing a contributor met
was a login page, and the GitHub mirror was the de-facto front door with 199 open pull
requests nobody here could see.

Three parts, because the problem had three faces:

1. scripts/cf-access-bypass.js now accepts either credential shape. A scoped token goes
   in a Bearer header; the account Global API Key goes in X-Auth-Email + X-Auth-Key.
   Getting that wrong returns '9103 Unknown X-Auth-Key or X-Auth-Email', which reads
   like a bad key when it is a bad header. test/cf-access-bypass-auth.test.js pins the
   mapping, including that the account-wide key is never used when a narrow token exists.

2. scripts/gh-bridge.js carries contributions inward: GitHub issues become Forgejo
   issues, GitHub pull requests become a gh/<n> branch pushed verbatim plus a Forgejo
   pull request so CI runs here, and merges are reported back to the contributor. Every
   imported object carries a <!-- gh-issue: N --> or <!-- gh-pr: N --> marker, so the
   script finds its own work by reading it back and is safe to re-run.

3. docs/PUBLIC-ACCESS.md records the arrangement: the whole forge is publicly readable,
   Forgejo's own accounts are the gate for writes, and the wildcard Access application
   still covers every other host on the domain.

Two defects the first live run exposed, both fixed here: the bridge commented the
internal API address onto public GitHub threads instead of the published hostname, and
it promised that replies would be carried back and forth when only new issues and pull
requests are. Both were live for two minutes on two real pull requests and both are
corrected there.

Access is configured as one application: git.jayw.uk -> bypass. A path-scoped variant
was tried first and removed - it made the repository browsable but left git clone dead,
because Forgejo clones through /packetforge.git, a different path prefix.

103 suites, 4963 assertions.
jaylouisw deleted branch feat/gh-bridge 2026-11-08 15:15:34 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
jaylouisw/packetforge!1074
No description provided.