Skip to content

Auth Middleware Builder

Verified

Generates authentication and authorization middleware for Node.js, Python, and Go APIs with JWT, API keys, and RBAC.

By Anthropic 8,900 v2.1.0 Updated 2026-03-10

Install

Claude Code

Copy the SKILL.md file to your project's .claude/skills/ directory

About This Skill

Auth Middleware Builder generates secure, production-tested authentication and authorization patterns for REST APIs. It understands the security implications of every decision and generates code that is both correct and auditable.

Authentication Strategies

JWT Bearer Authentication - Token validation with proper algorithm pinning (RS256 or HS256) - Claims extraction and type-safe request enrichment - Token expiration and refresh handling - Revocation support via token denylist (Redis)

API Key Authentication - Hashed key storage (never store plaintext API keys) - Key prefix for identification without exposing the secret - Per-key metadata: owner, scopes, expiration, rate limit tier

OAuth2 / OIDC - Token introspection against authorization server - JWT signature verification using JWKS endpoint - Scope-based access control

Authorization Patterns

Role-Based Access Control (RBAC) ``` roles: ["admin", "editor", "viewer"] permissions: { "posts:write": ["admin", "editor"], "posts:read": ["viewer"] } ```

Attribute-Based Access Control (ABAC) Policy evaluation functions for complex resource ownership checks.

Framework Support

  • Express.js — middleware functions and error handlers
  • Fastify — hooks and decorators
  • FastAPI — dependency injection pattern
  • Echo (Go) — middleware groups

Security Defaults

All generated code defaults to secure settings: strict algorithm validation, short JWT expiry, HttpOnly cookie flag for web apps, and constant-time comparison for secrets.

Use Cases

  • Adding JWT-based authentication to existing Express or FastAPI applications
  • Implementing role-based access control (RBAC) for multi-tenant APIs
  • Generating API key authentication with rate limiting integration
  • Creating middleware chains for request validation and logging

Pros & Cons

Pros

  • + Security-first defaults — no insecure patterns generated
  • + Supports JWT, API keys, and OAuth2/OIDC in one skill
  • + RBAC and ABAC patterns for complex authorization
  • + Works across Express, Fastify, FastAPI, and Go Echo

Cons

  • - Generated auth code must be reviewed by a security-aware developer before production deployment
  • - OAuth2 flows require additional configuration of the authorization server

Related AI Tools

Related Skills

Stay Updated on Agent Skills

Get weekly curated skills + safety alerts

每周精选 Skills + 安全预警