Skip to main content
Archery authentication combines persisted users with in-memory and persisted auth sessions; you will register login flows, verify passwords, and protect routes.

Register auth routes

Call authRoutes(router) after resolving your router. It registers guest-only GET /login and GET /register pages plus their POST handlers.
example/main.dart
The registration handler validates email, name, and password; creates a User; hashes the password; and redirects through the included response helpers.

Hash passwords

Use Auth.hashPassword() before persistence and Auth.verifyPassword() for an explicit comparison. The underlying Hasher uses PBKDF2-HMAC-SHA256 with a random salt, 25,000 iterations, a 32-byte key, a versioned string format, and constant-time comparison.
lib/src/http/routes/register.dart

Log in and resolve users

lib/src/http/routes/login.dart
Use await Auth.check(request) to test authentication, await Auth.user(request) or await request.user to load the current user, and await Auth.logout(request) to end the session.

Guard routes

lib/src/http/routes/api.dart
Auth.middleware redirects invalid sessions to login. Guest.middleware redirects authenticated users away from login and registration pages.
The archery_session cookie is created with httpOnly, secure, and SameSite.lax. Serve authentication flows over HTTPS so browsers send the secure cookie.