JWT Validator
VerifiedImplements secure JWT creation, validation, and rotation with proper algorithm selection, claim validation, and key management.
Install
Claude Code
Copy the SKILL.md file to your project's .claude/skills/ directory About This Skill
JWT Validator implements the JWT standard correctly — which is harder than it sounds. The JWT ecosystem has many common pitfalls that have caused real-world authentication bypasses at major companies.
Security Requirements Enforced
Algorithm Selection - **RS256 (recommended for APIs)** — asymmetric, private key signs, public key verifies. Authorization servers can distribute public key via JWKS without exposing signing capability. - **HS256** — symmetric, suitable only for internal systems where both sides are trusted. Never use for multi-tenant or public-facing APIs. - **Explicitly reject 'alg: none'** — the most common JWT vulnerability, blocked in generated code.
Claim Validation All generated validators check: - `exp` — token not expired (with configurable clock skew tolerance, default 30s) - `nbf` — not before time if present - `iss` — issuer matches expected value (strict string match, not prefix) - `aud` — audience includes your service identifier - `sub` — subject present and non-empty
Key Management
- JWKS Integration:
- For external JWT issuers (Auth0, Cognito, Google), generates key fetching from the `/.well-known/jwks.json` endpoint with:
- Key caching (TTL-based, with force-refresh on unknown `kid`)
- Key rotation support (multiple valid keys in JWKS)
RSA Key Generation: For issuing your own tokens — generates key pair creation code and rotation schedule.
Token Lifecycle
- Access token: 15 minutes, contains user identity and permissions claims
- Refresh token: 7-30 days, stored in database for revocation support
- Refresh rotation: each refresh generates a new refresh token (old invalidated)
Language Implementations
- Node.js with `jose` library (recommended, maintained by Panva)
- Python with `python-jose` or `PyJWT`
- Go with `golang-jwt/jwt`
- Java with `java-jwt` (Auth0)
Use Cases
- Implementing stateless API authentication with JWT access and refresh tokens
- Setting up JWT key rotation without service downtime
- Validating third-party JWTs from OAuth providers using JWKS
- Implementing short-lived tokens with refresh token rotation for mobile apps
Pros & Cons
Pros
- + Explicitly rejects 'alg: none' — the most exploited JWT vulnerability
- + Full claim validation including iss and aud strict matching
- + JWKS caching with rotation support for external identity providers
- + Refresh token rotation with database revocation support
Cons
- - JWT is stateless by design — revocation requires a denylist (Redis) for access tokens
- - Asymmetric key management (RSA key rotation) adds operational complexity
Related AI Tools
Claude Code
Paid
Anthropic's agentic CLI for autonomous terminal-native coding workflows
- Terminal-native autonomous coding agent
- Full file system and shell access for multi-step tasks
- Deep codebase understanding via repository indexing
Cursor
Freemium
AI-native code editor with deep multi-model integration and agentic coding
- AI-native Cmd+K inline editing and generation
- Composer Agent for autonomous multi-file changes
- Full codebase indexing and context awareness
GitHub Copilot
Freemium
AI pair programmer that suggests code in real time across your IDE
- Real-time code completions across 30+ languages
- Copilot Chat for natural language code Q&A
- Pull request description and summary generation
Related Skills
Auth Middleware Builder
VerifiedGenerates authentication and authorization middleware for Node.js, Python, and Go APIs with JWT, API keys, and RBAC.
OAuth Implementer
VerifiedImplements OAuth 2.0 and OIDC flows (authorization code, PKCE, client credentials) with provider-specific configurations for Google, GitHub, and more.
Secret Detector
CautionScans codebases, configuration files, and git history for exposed credentials, API keys, tokens, and other sensitive secrets that should not be committed.
Stay Updated on Agent Skills
Get weekly curated skills + safety alerts
每周精选 Skills + 安全预警