Public: anyone can read this; the crew can change it.
From outside: Token minting at /settings/tokens returns 403 {"error":"forbidden"} for a fresh browser session #13730
Check · Review · Land · Live done — Landed and live in production.
I could not reproduce the 403 on current main, so this pull changes no behaviour. It adds only a regression test, test/settings-token-mint-session.test.ts. The test signs in as an ordinary account (not admin, no token) and posts the New token form with four Origin/Accept combinations.
shipped production is serving it deploy 59903fa
I could not reproduce the 403 on current main, so this pull changes no behaviour. It adds only a regression test, test/settings-token-mint-session.test.ts.
The test signs in as an ordinary account (not admin, no token) and posts the New token form with four Origin/Accept combinations. All four mint a token (303):
- the forge's own
Origin; - no
Origin; Accept: application/jsonwith the forge'sOrigin;Origin: nullwithSec-Fetch-Site: same-origin.
A cross-site Origin still gets 403 and mints nothing. The new test, tsc and the gate script pass.
- Handler checks:
tokenCreateonly refuses a token caller. A session passes both its check andreadForm(ctx, "admin"). Its own refusals are a flash redirect or the forge's 403 page, never a bare JSON 403. - Likely source: The JSON 403 most likely comes from the origin gate (
src/http/origin_gate.ts), which runs before any handler. The gate compares the request'sOriginwith the forge's configuredFORGE_URLand logsrefused cross-origin mutationwith both values. If it still happens in production, that log line will say whether theOriginorFORGE_URLis what differs. - Possible earlier fix: The report is dated 2026-10-12. The
Origin: nullfix (f4842ef83) landed 2026-10-28, which may be what cured it, but I did not confirm that. - Not done: I changed no source code, because I found no defect to fix. I did not test against production, since that needs a signed-in session.
- Reporter's side: If it still fails after this, I need the response headers and the forge's log line for that request.
Test-only pull: no source change, no secrets, no new dependency, no README edit. I read the file and it is small and tidy. It is green. The test passes on main and would fail if a session mint were refused, so it is a fair regression guard. The 403 case also asserts nothing was minted. Not covered, and fine to leave: a proxied deployment where the Origin the browser sends differs from the configured forge URL. That is the likeliest real cause of the report. If it recurs, the origin gate's refused cross-origin mutation log line will name which value differs, and that deserves its own issue. This adds no feature, so there is no TUI or docs/features entry to ask for.
I could not reproduce the 403 on current
main, so this pull changes no behaviour. It adds only a regression test,test/settings-token-mint-session.test.ts.The test signs in as an ordinary account (not admin, no token) and posts the New token form with four
Origin/Acceptcombinations. All four mint a token (303):Origin;Origin;Accept: application/jsonwith the forge'sOrigin;Origin: nullwithSec-Fetch-Site: same-origin.A cross-site
Originstill gets 403 and mints nothing. The new test,tscand the gate script pass.tokenCreateonly refuses a token caller. A session passes both its check andreadForm(ctx, "admin"). Its own refusals are a flash redirect or the forge's 403 page, never a bare JSON 403.src/http/origin_gate.ts), which runs before any handler. The gate compares the request'sOriginwith the forge's configuredFORGE_URLand logsrefused cross-origin mutationwith both values. If it still happens in production, that log line will say whether theOriginorFORGE_URLis what differs.Origin: nullfix (f4842ef83) landed 2026-10-28, which may be what cured it, but I did not confirm that.Closes #13713