Wires up JWT bearer authentication in any stack with secure defaults: token issuing, validation, refresh tokens, and protected endpoints. Detects existing auth and hardens it.
Ships in AI for Developers Toolkit. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Wire up JWT bearer authentication in an API with secure defaults: token issuing, validation, refresh tokens, and protected endpoints. For detailed policy/permission design, hand off to authorization-setup.
If they point at a project or repo, inspect the existing auth setup before changing anything:
git clone --depth 1 <url> /tmp/repo && cd /tmp/repoIf auth already exists, review and harden it (validation flags, algorithm pinning, clock skew, refresh-token handling, where the signing key lives) rather than re-adding from scratch, and flag access-control gaps (unprotected endpoints, no deny-by-default).
| Manifest | Look for | Library |
|---|---|---|
*.csproj | Microsoft.AspNetCore.Authentication.JwtBearer | JwtBearer handler |
package.json | jose, jsonwebtoken, passport-jwt, @nestjs/jwt | jose / passport-jwt / Nest JwtModule |
pyproject.toml, requirements*.txt | pyjwt, fastapi, djangorestframework-simplejwt, authlib | PyJWT / SimpleJWT |
pom.xml, build.gradle(.kts) | spring-boot-starter-oauth2-resource-server | Spring Security Resource Server |
go.mod | github.com/golang-jwt/jwt/v5, github.com/lestrrat-go/jwx | golang-jwt / jwx |
grep -rn "AddJwtBearer\|TokenValidationParameters\|RequireHttpsMetadata" --include=*.cs <target>
grep -rn "jwtVerify\|jwt.verify\|JwtModule\|passport-jwt" --include=*.ts --include=*.js <target> | grep -v node_modules
grep -rn "jwt.decode\|OAuth2PasswordBearer\|SIMPLE_JWT" --include=*.py <target>
grep -rn "oauth2ResourceServer\|JwtDecoder\|issuer-uri" <target>/src
grep -rn "jwt.Parse\|jwt.WithValidMethods" --include=*.go <target>
Confirm whether they're issuing tokens themselves (own login) or validating tokens from an external IdP (Entra ID / Auth0 / Keycloak / Cognito). For an external IdP, validate against its issuer and JWKS endpoint and delegate issuing - this is the preferred path for most production systems. Self-issued is covered below for apps that own their login.
iss, aud, exp/nbf. Never disable validation to "make it work".HS256 or RS256); never accept alg: none and never let the token header pick the algorithm.kid.sub, jti, roles/permissions; no PII or secrets - JWTs are encoded, not encrypted.authorization-setup.revoked flag - not a JWT you can't revoke.HttpOnly; Secure; SameSite cookie, not localStorage.dotnet add package Microsoft.AspNetCore.Authentication.JwtBearer
dotnet add package System.IdentityModel.Tokens.Jwt
var jwt = builder.Configuration.GetSection("Jwt");
builder.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
.AddJwtBearer(options =>
{
// External IdP instead: options.Authority = "<issuer>"; options.Audience = "<api>";
options.TokenValidationParameters = new TokenValidationParameters
{
ValidateIssuer = true, ValidateAudience = true,
ValidateLifetime = true, ValidateIssuerSigningKey = true,
ValidIssuer = jwt["Issuer"], ValidAudience = jwt["Audience"],
IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(jwt["Key"]!)),
ValidAlgorithms = [SecurityAlgorithms.HmacSha256],
ClockSkew = TimeSpan.FromSeconds(30) // tighten the default 5 min
};
});
builder.Services.AddAuthorization(o =>
o.AddPolicy("CanManageOrders", p => p.RequireClaim("permission", "orders:manage")));
app.UseAuthentication();
app.UseAuthorization();
Token issuing:
public class TokenService(IConfiguration config)
{
public string CreateAccessToken(User user)
{
var jwt = config.GetSection("Jwt");
var claims = new List<Claim>
{
new(JwtRegisteredClaimNames.Sub, user.Id.ToString()),
new(JwtRegisteredClaimNames.Jti, Guid.NewGuid().ToString()),
new(ClaimTypes.Role, user.Role)
};
var key = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(jwt["Key"]!));
var token = new JwtSecurityToken(jwt["Issuer"], jwt["Audience"], claims,
expires: DateTime.UtcNow.AddMinutes(15),
signingCredentials: new SigningCredentials(key, SecurityAlgorithms.HmacSha256));
return new JwtSecurityTokenHandler().WriteToken(token);
}
}
Endpoints: .RequireAuthorization() / .RequireAuthorization("CanManageOrders"); current user via ClaimsPrincipal (user.FindFirstValue(JwtRegisteredClaimNames.Sub)). Set RequireHttpsMetadata = true in production. Bind the Jwt section through validated options (typed-config-generator). For full user management, point to ASP.NET Core Identity.
jwtVerify(token, key, { issuer, audience, algorithms: ['RS256'], clockTolerance: 30 }); for an IdP use createRemoteJWKSet(new URL(jwksUri)). Issue with new SignJWT(claims).setProtectedHeader({ alg }).setExpirationTime('15m').jsonwebtoken: always pass algorithms to jwt.verify.@nestjs/jwt JwtModule.registerAsync (secret from ConfigService) + @nestjs/passport JwtStrategy, registered as a global guard with a @Public() opt-out.passport-jwt or a small middleware around jwtVerify that sets req.user.jwt.decode(token, key, algorithms=["RS256"], audience=..., issuer=..., leeway=30) - algorithms is mandatory, keep it explicit. jwt.PyJWKClient(jwks_url) for IdP keys.OAuth2PasswordBearer(tokenUrl="token") + a get_current_user dependency that decodes and loads the user; apply via Depends / router dependencies.djangorestframework-simplejwt (SIMPLE_JWT settings: short ACCESS_TOKEN_LIFETIME, ROTATE_REFRESH_TOKENS = True, BLACKLIST_AFTER_ROTATION = True with the blacklist app).spring.security.oauth2.resourceserver.jwt.issuer-uri=<issuer> (discovers JWKS, validates iss/exp); add an audience validator on the JwtDecoder.http.oauth2ResourceServer(o -> o.jwt(Customizer.withDefaults()))
.authorizeHttpRequests(a -> a.anyRequest().authenticated());
JwtAuthenticationConverter (e.g. permissions claim -> hasAuthority).NimbusJwtEncoder / NimbusJwtDecoder with an RSA key pair; or delegate to Spring Authorization Server / Keycloak.github.com/golang-jwt/jwt/v5: jwt.Parse(token, keyFunc, jwt.WithValidMethods([]string{"RS256"}), jwt.WithIssuer(iss), jwt.WithAudience(aud), jwt.WithLeeway(30*time.Second)).github.com/MicahParks/keyfunc or lestrrat-go/jwx for remote key sets.context.Context, and returns 401 on failure.## What I'm setting up
<stack, self-issued vs external IdP, what's protected>
## Packages + wiring
...
## Token issuing / refresh
...
## Config & secrets
<config shape + where the key actually goes>
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
jwt, bearer-auth, token-validation, api-security, authentication-setup
45 skills in this plugin
/api-endpoint-scaffolderScaffold HTTP API endpoints in any stack - ASP.NET Core Minimal APIs or controllers, Express, Fastify, NestJS, FastAPI, Django REST Framework, Spring Boot controllers, Go net/http, chi, Gin - one feature per endpoint (REPR style) with request validation, typed responses, route grouping, auth, and OpenAPI metadata. Use this skill whenever the user wants to add an endpoint or route, convert controllers to minimal APIs, structure routes or routers, set up endpoint groups, TypedResults, route handlers, request DTOs/schemas (zod, Pydantic, Bean Validation, binding tags), or asks "how do I add an endpoint / structure my API routes". Always use this skill for endpoint scaffolding; it generates a complete, validated endpoint that matches the project's conventions./architecture-test-generatorGenerate architecture tests / fitness functions that fail the build when architectural rules are violated - layer dependencies, module boundaries, cycles, naming, and visibility conventions - in any stack: NetArchTest or ArchUnitNET (.NET), ArchUnit or Konsist (Java/Kotlin), dependency-cruiser or eslint-plugin-boundaries (TypeScript/JavaScript), import-linter (Python), go-arch-lint or depguard (Go). Use this skill whenever the user wants architecture tests, to enforce layering or the dependency rule, dependency rules as tests, import rules, forbidden imports, no circular dependencies, naming conventions, fitness functions, or asks "how do I stop people breaking the architecture / enforce my layers / keep modules from importing each other". Always use this skill for architecture-test requests; it generates rules matching the project's real structure./async-await-auditorAudit async and concurrent code in any language for correctness and performance bugs - C#/.NET (async/await, Task), JavaScript/TypeScript (Promises, async/await), Python (asyncio), Java/Kotlin (CompletableFuture, virtual threads, coroutines), Go (goroutines, channels, context), Rust (tokio/async). Use this skill whenever the user shares async or concurrent code, or asks about deadlocks, hangs, blocking calls, .Result/.Wait(), async void, ConfigureAwait, floating or unhandled promises, await in a loop vs Promise.all, blocking the event loop, forgotten await, asyncio.gather/TaskGroup, CompletableFuture.join, virtual thread pinning, goroutine leaks, context cancellation, WaitGroup/errgroup, holding a lock across .await, fire-and-forget tasks, cancellation tokens, or "why does my async code hang". Always use this skill for async/concurrency reviews instead of answering from memory; it applies a fixed checklist and rewrites the code./authorization-setupDesign API authorization in any stack - policy-based, role-based, claims/permission-based, and resource-based (ownership) checks. Covers ASP.NET Core policies and AuthorizationHandler, NestJS guards, Express middleware and CASL, FastAPI dependencies/scopes, Django and DRF permission classes, Spring Security (@PreAuthorize, SecurityFilterChain), Go middleware, and Casbin/OPA. Use this skill whenever the user wants authorization policies, role/claim/permission checks, RBAC/ABAC, custom authorization rules, resource-based authorization, IDOR protection, "deny by default", or asks "how do I authorize this / policy vs role / restrict this endpoint to X / stop users seeing other users' data". Always use this skill for authorization requests; it generates policies, handlers, and endpoint wiring./benchmark-setupSet up correct micro-benchmarks in any stack and interpret the results - BenchmarkDotNet (.NET), JMH (Java/Kotlin), pytest-benchmark / pyperf (Python), Vitest bench / tinybench / mitata (JavaScript/TypeScript), Go testing.B + benchstat, Rust criterion. Use this skill whenever the user wants to benchmark code, measure performance, compare two implementations or functions, set up a benchmark harness, or asks "which is faster", "benchmark these two functions", "how do I benchmark this", "is this optimization worth it", or "interpret these benchmark results". Always use this skill for micro-benchmarking requests; it writes correct benchmarks, avoids the classic pitfalls, and explains the numbers./caching-strategy-setupAdd the right caching to an app in any stack - in-process, distributed (Redis/Valkey/Memcached), two-level, or HTTP/output caching - with correct keys, expiration, stampede protection, and invalidation. Covers HybridCache / IMemoryCache / IDistributedCache / output caching in .NET, lru-cache / keyv / cache-manager / ioredis in Node, functools / cachetools / redis-py / Django cache in Python, Spring Cache with Caffeine or Redis in Java/Kotlin, and ristretto / groupcache / singleflight / go-redis in Go. Use this skill whenever the user wants caching, to cache a query/response, Redis caching, @Cacheable, lru_cache, HybridCache, cache-aside, output caching, or asks "how do I cache this / add caching / avoid cache stampede / invalidate this cache". Always use this skill for caching requests; it picks the right layer and wires expiration + invalidation correctly./ai-dev-toolkit:jwt-auth-setupfrom AI for Developers Toolkit
npx claudepluginhub stefanthecode/ai-for-developers --plugin ai-dev-toolkitOther plugins' skills for the same job