eaccess auth
Session-based Express authentication for PostgreSQL. Roles, MFA, OAuth, and an admin UI. Everything lives on req.auth.
What it does
- Session-based auth with
express-sessionand PostgreSQL storage - Drop-in middleware that puts an auth manager on every request
- Custom roles via bitmask (
defineRoles) or built-in defaults - 2FA: TOTP, email OTP, SMS OTP, backup codes
- OAuth: GitHub, Google, Azure
- Remember-me with persistent tokens
- Admin UI for user management
- Maps to your existing user tables via
user_id- no schema migration needed
How it works
- Add
express-sessionand the auth middleware to your Express app - Call
createAuthTables(config)once to set up the database tables - Every request gets
req.authwith methods for login, register, roles, MFA, OAuth - Optionally mount the admin UI for user management
Stack
| Layer | Implementation |
|---|---|
| Sessions | express-session |
| Storage | PostgreSQL via pg Pool |
| Auth | req.auth (AuthManager) |
| Roles | Bitmask with defineRoles() |
| MFA | TOTP + OTP + backup codes |
| OAuth | GitHub, Google, Azure |
| Admin | Vue 3 SPA served from Express |