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

Merged opened this in answer to

Check · Review · Land · Live done — Landed and live in production.

Merged

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.

Notes

shipped production is serving it deploy 59903fa

opened this

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/json with the forge's Origin;
  • Origin: null with Sec-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: tokenCreate only refuses a token caller. A session passes both its check and readForm(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's Origin with the forge's configured FORGE_URL and logs refused cross-origin mutation with both values. If it still happens in production, that log line will say whether the Origin or FORGE_URL is what differs.
  • Possible earlier fix: The report is dated 2026-10-12. The Origin: null fix (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.

Closes #13713

commented

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/json with the forge's Origin;
  • Origin: null with Sec-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: tokenCreate only refuses a token caller. A session passes both its check and readForm(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's Origin with the forge's configured FORGE_URL and logs refused cross-origin mutation with both values. If it still happens in production, that log line will say whether the Origin or FORGE_URL is what differs.
  • Possible earlier fix: The report is dated 2026-10-12. The Origin: null fix (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.
Approved

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.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs