Install
$ agentstack add skill-lonsdale201-wp-agent-skills-br-jwks-jwt-auth ✓ scanned · ✓ verified — works with Claude Code, Cursor, and more.
Security review
✓ PassedNo issues found. Passed automated security review. · v0.1.0 How review works →
- ✓ Prompt-injection patterns
- ✓ Secret / credential exfiltration
- ✓ Dangerous shell & filesystem operations
- ✓ Untrusted network calls
- ✓ Known-malicious package signatures
What it can access
- ✓ Network access No
- ✓ Filesystem access No
- ✓ Shell / process execution No
- ✓ Environment & secrets No
- ✓ Dynamic code execution No
From automated source analysis of v0.1.0. “Used” means the capability is present in the source — more access means more to trust, not that it’s unsafe.
About
better-route: JWKS JWT auth
Use this for OIDC/OAuth-style bearer JWTs signed with asymmetric keys. In better-route 0.6.0 the library ships Rs256JwksJwtVerifier, so do not write a custom verifier for normal RS256 or ES256 JWKS use cases.
Pattern
use BetterRoute\Middleware\Auth\BearerTokenAuthMiddleware;
use BetterRoute\Middleware\Auth\JwtBearerTokenVerifierAdapter;
use BetterRoute\Middleware\Jwt\HttpJwksProvider;
use BetterRoute\Middleware\Jwt\Rs256JwksJwtVerifier;
$jwks = new HttpJwksProvider(
jwksUri: 'https://issuer.example.com/.well-known/jwks.json',
ttlSeconds: 3600,
issuer: 'https://issuer.example.com'
);
$verifier = new Rs256JwksJwtVerifier(
jwks: $jwks,
leewaySeconds: 60,
expectedIssuer: 'https://issuer.example.com',
expectedAudience: 'my-api',
requireExpiration: true,
maxLifetimeSeconds: 3600,
allowedAlgorithms: ['RS256']
);
$auth = new BearerTokenAuthMiddleware(
verifier: new JwtBearerTokenVerifierAdapter($verifier),
requiredScopes: ['orders:read']
);
For write routes, still call ->protectedByMiddleware('bearerAuth') so WordPress dispatches to the middleware pipeline.
Critical rules
kidin the JOSE header is required and must match exactly one usable JWKS key.- On
kidmiss, the verifier callsJwksProviderInterface::refresh()once, then fails closed. - Never fall back to "try every public key"; that accepts stale or unrelated keys.
allowedAlgorithmssupportsRS256andES256;noneandHS*are rejected even if accidentally configured.HttpJwksProviderrequires anhttpsURI and usessslverify => true.- Private JWK fields are stripped by
JwksKeySanitizer; JWKS should contain public keys only. - Set
expectedIssuerandexpectedAudiencein production. - Keep
requireExpiration: true; disabling it is a migration-only decision.
JWKS cache invalidation
HttpJwksProvider listens for:
do_action('better_route/jwks_refresh', 'https://issuer.example.com');
Use this from admin tooling after key rotation or when forcing a cache clear.
Tests
Use StaticJwksProvider for unit tests:
$verifier = new Rs256JwksJwtVerifier(
new StaticJwksProvider([$publicJwk]),
now: static fn (): int => 1700000000
);
Cross-references
- Use
br-auth-middlewarefor generic auth middleware choice andprotectedByMiddleware()route intent. - Use
br-error-contractfor the401 invalid_tokenresponse shape. - Use
br-cryptowhen generating nonces, state, PKCE values, or doing token-bound string compares.
Source & license
This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.
- Author: Lonsdale201
- Source: Lonsdale201/wp-agent-skills
- License: MIT
Install and usage instructions live in the source repository linked above.
Reviews
No reviews yet — be the first.
Write a review
Versions
- v0.1.0 Imported from the upstream source.