Skip to content

sutegi 0.8.0 — the production user system (remember me, throttling, CSRF, hash-bound sessions) - #12

Merged
enekos merged 3 commits into
masterfrom
auth-hardening
Jul 27, 2026
Merged

enekos merged 3 commits into
masterfrom
auth-hardening

Conversation

@enekos

@enekos enekos commented Jul 27, 2026

Copy link
Copy Markdown
Owner

What

Closes the gap between sutegi-auth and Laravel's auth scaffolding, still with zero third-party dependencies:

  • Remember me (sutegi_auth::Remember): selector/validator cookies — only the validator's SHA-256 is stored, the validator rotates on every use (a replayed stolen copy revokes the row, surfacing the theft), tokens are bound to the password hash (password change kills them), server-side 30-day expiry. Auth::identify is the handler-side revival point; logout_from / logout_everywhere revoke.
  • Login throttling (sutegi_auth::Throttle): DB-backed fixed window (5/60 s per key, atomic increments) — every pod counts the same attempts.
  • CSRF: Sessions::csrf / verify_csrf (constant-time) + the require_csrf guard — 419 on mismatch, reads and Authorization-header callers pass.
  • Hash-bound sessions: Auth::login stamps a fingerprint of the PHC string; current/identify treat a stale binding as anonymous → password change logs out every other device. Lenient on 0.7 sessions (no fingerprint), strict on mismatch.
  • Auto-rehash at login when the stored iteration count lags the store's.
  • require_verified guard; Users::change_password/set_name/set_email (email change resets verification).
  • Token lifecycle: Tokens::issue_expiring + last_used_at stamping; in-place table upgrade.

examples/auth exercises remember/revival/throttle/logout end to end. Workspace bumped to 0.8.0, CHANGELOG updated.

Breaking

  • Auth gains a public remember: Option<Remember<B>> field — struct-literal constructions need remember: None (Auth::new unaffected).

Tests

Full workspace green: 86 suites, 0 failures — including 46 sutegi-auth unit tests (rotation chains, theft response, bind kills, throttle windows, CSRF constant-time, revival cookie round-trips).

Consumer

bildu's multi-user system (PR to follow in the-yolo-company/bildu) is built on this release.

enekos added 3 commits July 27, 2026 14:35
…ing, CSRF, hash-bound sessions

Everything Laravel auth scaffolding does, still zero third-party deps:

- Remember me (sutegi-auth::remember): selector/validator cookies, only the
  validator SHA-256 stored, rotation on every use (replayed copies revoke the
  row), bound to the password hash so password changes kill tokens silently,
  30-day server-side expiry. Auth::login_remembered mints; Auth::identify is
  the handler-side session-or-remember revival point (middleware cannot set
  cookies on pass-through); logout_from / logout_everywhere revoke.
- Login throttling (sutegi-auth::throttle): DB-backed fixed window,
  5 attempts / 60 s per key, atomic increments — every pod counts the same.
- CSRF: Sessions::csrf get-or-mints a 32-byte token inside the signed
  session, verify_csrf compares constant-time, require_csrf guards mutating
  methods (419) while passing reads and Authorization-header callers.
- Sessions bound to a password-hash fingerprint: Auth::current/identify
  treat a stale binding as anonymous — password change logs out every other
  device. user_id stays pure cookie-HMAC (documented).
- Auto-rehash at login when the stored work factor lags the store setting.
- require_verified guard; Users::change_password (current-password check),
  set_name, set_email (resets verified_at).
- Tokens: issue_expiring + last_used_at stamping, tolerant table upgrade.
- examples/auth exercises remember/revival/throttle/logout end to end.

Workspace bumped to 0.8.0; CHANGELOG has the full notes.
@enekos
enekos merged commit ba027c8 into master Jul 27, 2026
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant