What problem does it solve?
Implementing JSON Web Token authentication correctly is error-prone, and mistakes like accepting unsigned tokens or allowing algorithm confusion lead to critical authentication bypasses. This Skill guides the implementation of secure JWT signing, verification, and claims validation while defending against the most common JWT attacks.
Core Features & Use Cases
- Multi-Algorithm Signing: Implement JWT signing with HS256, RS256, ES256, and EdDSA, with guidance on when to choose symmetric versus asymmetric algorithms.
- Attack Defense: Prevent algorithm confusion (RS256 to HS256), alg:none acceptance, weak HMAC secrets, and kid/jku/jwk header injection through pinned algorithms and key allowlists.
- Claims Validation & Key Rotation: Enforce exp, nbf, aud, and iss claims, and implement JWK Set-based key rotation plus a complete authentication middleware.
- Use Case: When building a token-based login system for a web API, use this Skill to sign short-lived access tokens with EdDSA, verify them with a pinned algorithm allowlist, and confirm that tampered, expired, and wrong-audience tokens are all rejected.
Quick Start
Implement JWT signing and verification in Python with HS256 and RS256, including expiration and audience validation and tests proving that alg:none and algorithm-confusion tokens are rejected.