Security

Auth & Security

Sessions, OAuth, secrets and access checks that fail closed

13 guides in this collection

Security

Session Cookies That Carry Nothing

A session cookie is a random token with no data in it. The server stores a hash of the token, and identity lives in the database row the hash finds.

3 min read
Security

Re-read Privileges on Every Request

A session proves who someone is. What they may do is read from the database on each request, so removing a role takes effect on the next click.

3 min read
Security

OAuth State: Signed, Stored, and Used Once

The state value is a signed cookie and a hashed database row. The callback verifies both and consumes the row in one atomic update, so a replay fails.

3 min read
Security

First-Run Setup Behind a Setup Secret

The route that creates the first owner is the most dangerous one in a new deploy. Gate it with a bearer secret, lock it after one use, and undo partial writes.

3 min read
Security

Safe Return Paths After Login

A return-to value must be a path on your own site. Checking for a leading slash is not enough, because browsers read a slash and a backslash as a new host.

3 min read
Security

Mask Personal Data in Admin Views

Admin screens get shared, recorded and screenshotted. Mask names, emails and addresses on the server by default, and make a reveal explicit, short and logged.

3 min read
Security

Machine Endpoints That Fail Closed

Cron routes and webhooks have no user to sign in. Give each a secret, compare it in constant time with one shared helper, and answer 503 while it is unset.

3 min read
Security

A Localhost Server Still Needs a Guard

Binding to 127.0.0.1 keeps other machines out. It does not keep out the web pages open in your own browser, which can post to localhost freely.

3 min read
Navigation

Fetch a User-Supplied URL Safely

A URL that a user or tenant chose can point at your own network. Send it through one fetcher that checks the address at every redirect, with a timeout and a size cap.

3 min read