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 Jwt Security?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/adityaaatiwari-jwt-security)
---
description: Issue and validate JWTs safely with strict alg pinning, JWKS rotation, short TTLs, and refresh token revocation
profile: standard
tags: auth, security, jwt, backend
---
# JWT security
Use when issuing access/refresh tokens, configuring JWKS verification, or auditing stateless authentication middleware.
## Token validation
- Always pin explicit expected signing algorithms (`["RS256"]` or `["EdDSA"]`) in verification options—never allow `none` or mix symmetric `HS256` with public keys via untrusted headers.
- Validate `iss` (issuer), `aud` (audience), `exp`, and `nbf` strictly on every request, ignoring unverified header `jku`/`x5u` URLs from tokens.
- Keep JWT access token TTLs short (`5–15` minutes) and exclude PII or secrets from unencrypted JWT claims.
## Rotation and revocation
- Support overlapping signing keys in JWKS (`kid`) cleanly during key rotation with bounded cache refresh on unknown `kid`.
- Store opaque refresh tokens hashed (SHA-256) in the database, rotate on every use (`refresh token rotation`), and revoke the entire token family immediately if reuse is detected.
## Verify
Test `alg: none` forgery, wrong `aud`/`iss`, expired tokens, key rotation rollover, and refresh-token reuse detection.