Smeltery
Get started

Alloy

v0.1

Redirects and history

  • Redirect::to(url) and Back answer 303. A 302 answer to an Inertia PUT, PATCH or DELETE becomes 303. A redirect to a URL with a #fragment becomes 409 with X-Inertia-Redirect, and an empty 200 becomes a redirect back.
  • alloy::location(url) leaves the app with a full page load (OAuth, a download, another site): 409 with X-Inertia-Location for Inertia visits, 303 otherwise. Pass only URLs the app chose, never user input.
  • An Inertia GET of a Mold page (the Watchfire dashboard) gets 409 X-Inertia-Location: a full page load.
  • X-Inertia-Location for the request itself and the page's url hold the request's path and query starting with exactly one /: leading slashes and backslashes become one / (//evil.example/x becomes /evil.example/x), so the client never resolves them to another site.
  • alloy::clear_history(&session) sets clearHistory on the next page; the kits call it on logout.
  • The browser keeps every page's props in its history. With .encrypt_history() (on the Alloy builder, or .encrypt_history(true) on a page) the client encrypts them with a key it drops on clearHistory, so the back button cannot show a signed-in page after logout. The client encrypts only in a secure context: over HTTPS, or on 127.0.0.1 / localhost; elsewhere it keeps the history unencrypted and logs a warning in the browser console. The kits with authentication turn it on.

↑↓ moveEnter openEsc close