auth-security

Implement JWT authentication and endpoint protection for FastAPI apps.

Updated Dec 31, 2025
One-click install
npx skills add https://github.com/Jawad-Chaudhary/Hackathone-2-TODO-Spec-Driven-Development --skill auth-security-jawad-chaudhary
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: auth-security
Source: https://github.com/Jawad-Chaudhary/Hackathone-2-TODO-Spec-Driven-Development/tree/main/Phase03/.claude/skills/auth-security
Command: npx skills add https://github.com/Jawad-Chaudhary/Hackathone-2-TODO-Spec-Driven-Development --skill auth-security-jawad-chaudhary

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill provides a reusable JWT verification flow and endpoint protection for FastAPI applications, ensuring only authenticated users can access protected routes.

Core Features & Use Cases

  • JWT verification middleware for protected endpoints
  • Enforce user_id matching between token payload and URL parameters
  • Security checklist covering secret management, token validation, and safe error responses
  • Example use: protecting a route like /api/{user_id}/resource in a multi-user application

Quick Start

Integrate the verify_jwt middleware into your FastAPI app and protect a route such as /api/{user_id}/resource.

Frequently Asked Questions about auth-security

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I verify JWT tokens and protect FastAPI endpoints?

To verify JWT tokens and protect FastAPI endpoints, you integrate a verify_jwt middleware that intercepts requests, validates the token, and ensures only authenticated users can access protected routes.

How does JWT authentication enforce user_id matching in FastAPI routes?

JWT authentication enforces user_id matching by comparing the user identifier in the token payload against the user_id parameter in the URL, such as /api/{user_id}/resource, preventing unauthorized cross-user access.

What is included in a security checklist for handling JWT authentication?

A security checklist for JWT authentication includes proper secret management via environment variables, strict token validation, comprehensive request validation, and returning safe error responses without exposing sensitive data.

Do I need environment secrets to implement JWT verification in FastAPI?

Yes, you need environment secrets to implement JWT verification in FastAPI. The middleware requires these secrets to securely sign and validate tokens, ensuring the authentication process remains tamper-proof.

Can I use this JWT middleware for multi-user FastAPI applications?

Yes, you can use this JWT middleware for multi-user FastAPI applications. It is specifically designed to protect routes like /api/{user_id}/resource by enforcing user_id matching between the token and URL parameters.