Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Auth And Sessions?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/ansh44233-auth-and-sessions)
---
description: Implement or review authentication, sessions, tokens and password handling without common security mistakes
profile: standard
tags: security, auth, backend
---
# Authentication and sessions
Use when touching login, signup, password reset, sessions, tokens or OAuth.
## Prefer proven building blocks
Use the framework's auth or a maintained library or provider. Do not invent token formats, crypto or password storage.
## Passwords
- Hash with argon2id, scrypt or bcrypt (with a reasonable work factor); never MD5/SHA-x alone, never reversible encryption.
- Rate-limit and add backoff to login and reset endpoints. Give the same response for unknown users and wrong passwords.
- Reset tokens: random, single-use, short-lived, stored hashed, and invalidated after a password change.
## Sessions and tokens
- Session cookies: `HttpOnly`, `Secure`, `SameSite=Lax` (or `Strict`), and rotate the session id on login and privilege change.
- JWTs: verify signature, `exp`, `iss` and `aud`; pin the algorithm (reject `none`). Keep them short-lived and use refresh tokens with rotation and revocation. Do not store long-lived tokens in `localStorage`.
- Logout must invalidate server-side sessions or refresh tokens.
## OAuth / OIDC
Authorization code flow with PKCE, validate `state` (and `nonce` for OIDC), exact redirect URI matching, and minimal scopes.
## Authorization
Check permissions on every request for the specific object (IDOR is the most common bug). Default deny.
## Verify
Tests for: wrong password, expired token, tampered token, reused reset token, another user's object id (expect 403/404), and rate limiting. Never log passwords or tokens.