Node Authentication Patterns
A guide to implementing secure authentication in Node.js applications with JWT, sessions, OAuth, and passwordless strategies.
Usage
Ask about authentication implementation, JWT patterns, OAuth setup, or session management.
Examples
- "Implement JWT authentication with refresh token rotation"
- "How do I set up OAuth 2.0 with Passport.js?"
- "Build a passwordless magic link login"
Guidelines
- Use bcrypt or argon2 for password hashing, never SHA or MD5
- Store tokens in httpOnly, secure, sameSite cookies
- Implement token refresh rotation to limit token theft impact
- Use short-lived access tokens with longer-lived refresh tokens
- Always validate and sanitize authentication inputs