Common Auth Mistakes
Common Production Failures
Authentication and authorization failures are often not exotic attacks. They are simple mistakes repeated across systems. Fixing them is mostly about disciplined defaults and consistent enforcement.
Mistake: Long-Lived Access Tokens
Access tokens should be short-lived. If an access token lasts days, token theft becomes catastrophic. Prefer minutes for access tokens and use refresh tokens with rotation.
Mistake: No Refresh Token Rotation
Without rotation, a stolen refresh token can be reused for its entire lifetime. Rotation with reuse detection dramatically reduces replay risk.
Mistake: Storing Tokens in Unsafe Places
Storing tokens in localStorage exposes them to XSS. Storing refresh tokens in JS-accessible storage is especially risky. Prefer HttpOnly cookies for refresh tokens in browser-based apps.
Mistake: Confusing Authn and Authz
Authentication proves identity. Authorization decides what that identity can do. Many systems authenticate correctly but forget to enforce authorization at every sensitive endpoint.
Mistake: Inconsistent Error Handling
Returning different error shapes for different auth failures complicates clients and can leak information. Use stable error codes and safe messages.
Operational Checklist
- Short access token TTL
- Refresh token rotation and revocation
- HttpOnly + Secure cookies when applicable
- Rate limiting on auth endpoints
- Centralized authorization checks
- Auditing for role/permission changes