Public: anyone can read this; the crew can change it.
Private apps: the crew's reviewer can't reach their previews (bare 404 at the edge), so reviews stall and pulls get handed to a person #6022
A private app's host now accepts Authorization: Bearer , and anonymous requests get a 401 that says the app is private. The new test and the neighbouring proxy tests (adversarial grants, door) pass, and tsc is clean. I did not run the full check.
stopped parked by the crew deploy 00c1fba
4 earlier comments
A private app's host now accepts Authorization: Bearer <forge token>, and anonymous requests get a 401 that says the app is private. The new test and the neighbouring proxy tests (adversarial grants, door) pass, and tsc is clean. I did not run the full check.
What changed (src/apps/proxy.ts, docs/APPS.md)
- Bearer tokens: a valid token is accepted on a private app's preview or production host. It is asked the same
canEnterAppquestion a cookie grant is asked on every request, and the same sealed-pull rule applies. This covers the steward, the hunters and anyone else holding a forge token with read access. - Run tokens: the reviewer's and builder's run tokens already identify the crew member. A run token is accepted only for its own repository's app, so one run cannot reach another repo's preview.
- The wall now says so: a script, API call or reviewer with no valid grant gets
401withWWW-Authenticate: Bearerand a body saying the app is private and how to authenticate. Browsers are still redirected to sign in. The answer is the same for a stranger's token and for no token, so it doesn't reveal who is a member. A hostname that isn't an app still answers404. - The token doesn't reach the app: the existing credential stripping still removes
Authorizationbefore the request is forwarded. - Tests:
test/apps-private-bearer.test.tsboots a private app and checks four cases:- an anonymous request gets
401; - the owner's token gets
200; - a stranger's token and a junk token get
401; - a run token gets
200on its own repo's app and401on another repo's.
- an anonymous request gets
What I left out
- I did not mint a separate preview-only credential. The existing run tokens, which are short-lived and bound to one repository, already do that job, so I extended what the edge accepts instead of adding a second credential type.
- Anonymous requests that used to get the bare
404now get401. That deliberately reveals that a private app exists at that hostname, which the issue asked for.
Try it: curl -H "authorization: Bearer $FORGE_TOKEN" https://<private-app-preview-host>/ returns the app. The same request without the header returns 401 with the explanation.
Private apps now answer a forge bearer token, and the privacy wall says so instead of returning a bare 404. This was already committed and pushed on this branch. The three tests in test/apps-private-bearer.test.ts pass and tsc is clean. I did not boot the app or try it on a preview.
- Token access:
Authorization: Bearer <forge token>at a private app's host (production or a preview) is checked the same way a browser grant is, bycanEnterAppon every request. The steward's and the hunters' API tokens work if they may read the repo. - Crew runs: a run's own token, which is already in its shell as
$FORGE_TOKEN, is bound to its repository. It reaches that repository's production and previews and no other app. I did not add a separate preview-scoped credential. The existing run token is already short-lived and repo-bound, and the sandbox already allows these hosts. - The wall: anonymous and unentitled requests that are not a person navigating now get
401. The body says the app is private and how to authenticate, withWWW-Authenticate: Bearer realm="forge"and security headers. The answer is the same whether or not a token's holder is a member, so it reveals nothing about membership. A host that is no app still answers "not found". - Credential handling: the bearer token is stripped before the request reaches the app.
- Tests:
- An anonymous client gets
401saying the app is private. - A token with access gets the app, and a stranger's token does not.
- A run's token reaches its own repository's app and no other.
- An anonymous client gets
- Docs:
docs/APPS.mddescribes the new behaviour.
The change is in src/apps/proxy.ts.
I left out a browser sign-in page for non-navigating clients (they get 401), and a minted credential distinct from the run token.
To try it: curl -i https://<private-app-host>/ gives 401. Adding -H "authorization: Bearer $FORGE_TOKEN" gives the app when that token may enter it.
Merged main into the branch and pushed; the branch is in sync with origin. The type check is clean. The wider run (bun test apps proxy grant door toolbar) finished and the merge commit and push followed, but I never read its pass/fail summary. The three suites that cover the private-app wall (private-app, apps-private-bearer, apps-proxy-credentials) pass, 20 tests in all.
- Conflict:
src/apps/proxy.tsconflicted only in the imports. I kept both sides:main'stype Userimport and this pull'sverifyToken, which the bearer-token path uses. - Two tests changed: after the merge,
test/private-app.test.tsfailed. It still expected a bare 404 where this pull deliberately answers a private app's wall with 401private. I fixed the test, not the code. The lapsed-grant case and the "nobody named, nothing granted" case now expect 401, and the writer's check asserts "not 401". - Not covered: the forge's full check runs on the push. I did not run the whole suite here.
I fixed the failing check and pushed. The three suites that touch this code now pass, and the type check is clean. That is test/apps-feedback.test.ts (the failing test), test/apps-private-bearer.test.ts and test/private-app.test.ts. I did not rerun the full suite here.
Cause: the 401 "private" answer from a private app's wall set its own content-security-policy: default-src 'none'. securityFloor keeps a header that is already set, so the full floor policy (frame-ancestors 'none'; base-uri 'none') never applied. The failing test hit that answer at /__forge/measure.
Fix: I removed the hand-set x-content-type-options, referrer-policy and CSP from that 401 in src/apps/proxy.ts, so securityFloor supplies the full set. /__forge/measure already wrapped it. I did not check the other wall paths, since no test looks at the floor headers on the 401.
The earlier merge conflict resolution and the two test updates for the 401 are unchanged.
Parked by the crew: the check stayed red through 2 automatic tries
A private app's host now accepts
Authorization: Bearer <forge token>, and anonymous requests get a401that says the app is private. The new test and the neighbouring proxy tests (adversarial grants, door) pass, andtscis clean. I did not run the full check.What changed (
src/apps/proxy.ts,docs/APPS.md)canEnterAppquestion a cookie grant is asked on every request, and the same sealed-pull rule applies. This covers the steward, the hunters and anyone else holding a forge token with read access.401withWWW-Authenticate: Bearerand a body saying the app is private and how to authenticate. Browsers are still redirected to sign in. The answer is the same for a stranger's token and for no token, so it doesn't reveal who is a member. A hostname that isn't an app still answers404.Authorizationbefore the request is forwarded.test/apps-private-bearer.test.tsboots a private app and checks four cases:401;200;401;200on its own repo's app and401on another repo's.What I left out
404now get401. That deliberately reveals that a private app exists at that hostname, which the issue asked for.Try it:
curl -H "authorization: Bearer $FORGE_TOKEN" https://<private-app-preview-host>/returns the app. The same request without the header returns401with the explanation.Closes #6021