fastify-xauth-jwks
Path-based JWT/JWKS validation plugin supporting multiple providers per route.
fastify-xauth-jwks
Path-based JWT validation using JWKS (JSON Web Key Sets). Protects multiple route paths with independent JWKS providers.
Installation
npm install @xenterprises/fastify-xauth-jwks
Quick Start
await fastify.register(xAuthJWKS, {
providers: [
{
paths: ['/api/user/**'],
jwksUri: 'https://auth.example.com/.well-known/jwks.json',
audience: 'https://api.example.com',
issuer: 'https://auth.example.com',
},
{
paths: ['/api/admin/**'],
jwksUri: 'https://admin-auth.example.com/.well-known/jwks.json',
audience: 'https://admin.example.com',
issuer: 'https://admin-auth.example.com',
},
],
})
AI Context
package: "@xenterprises/fastify-xauth-jwks"
type: fastify-plugin
use-when: APIs that need to validate JWTs from multiple auth providers (e.g., user JWT from Auth0, admin JWT from separate provider)
key-feature: path-based provider routing — different routes use different JWKS endpoints
request.user: set automatically after successful validation
no-env-required: JWKS URI is in config, fetched at runtime
