skills/awais68/jwt-auth/SKILL.md
Use when implementing JWT authentication in FastAPI or Python projects. Triggers for: token generation, verification middleware, current user extraction, access token creation, token decoding, or role-based auth. NOT for: OAuth2 provider setup, OpenID Connect, or non-Python backends.
npx skillsauth add aiskillstore/marketplace jwt-authInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Expert implementation of JWT token generation, verification, and user extraction for FastAPI and Python applications.
| Operation | Function | Location |
|-----------|----------|----------|
| Generate token | create_access_token(data, expires_delta=None) | auth/jwt.py |
| Verify token | verify_token(token: str) | auth/dependencies.py |
| Get current user | get_current_user(token: str) | auth/dependencies.py |
| User from payload | User.from_payload(payload) | auth/dependencies.py |
from auth.jwt import create_access_token
# Basic token with subject
token = create_access_token(data={"sub": "[email protected]"})
# Token with custom expiry (minutes)
from datetime import timedelta
token = create_access_token(
data={"sub": "[email protected]", "roles": ["admin"]},
expires_delta=timedelta(minutes=15)
)
# Token with roles for RBAC
token = create_access_token(data={"sub": "[email protected]", "roles": ["editor", "viewer"]})
Claims structure:
sub (required): User identifier (email, ID, or username)exp (auto): Expiration timeroles (optional): List of role strings for authorizationfrom fastapi import APIRouter, Depends
from auth.dependencies import get_current_user
router = APIRouter()
@router.get("/protected")
def protected_route(user = Depends(get_current_user)):
return {"message": f"Hello, {user.email}"}
from auth.dependencies import get_current_user, RoleChecker
# Define role checker
admin_only = RoleChecker(allowed_roles=["admin"])
@router.delete("/admin-only")
def admin_endpoint(user = Depends(admin_only)):
return {"message": "Admin access granted"}
from auth.dependencies import get_current_user
# User model automatically extracted from JWT claims
@router.get("/me")
def get_me(user = Depends(get_current_user)):
return {
"email": user.email,
"roles": user.roles,
"is_active": user.is_active
}
revoked_tokens set)algorithm="none"exp claim; reject expired tokensHeader:
{
"alg": "HS256",
"typ": "JWT"
}
Payload:
{
"sub": "[email protected]",
"roles": ["user", "editor"],
"exp": 1704067200,
"iat": 1704063600
}
Signature: HMAC-SHA256(secret, header.payload)
class User:
email: str
roles: List[str]
is_active: bool = True
@classmethod
def from_payload(cls, payload: dict) -> "User":
"""Extract User from decoded JWT payload."""
return cls(
email=payload.get("sub", ""),
roles=payload.get("roles", []),
is_active=payload.get("is_active", True)
)
The backend JWT implementation pairs with the frontend auth integration skill:
auth/jwt.py and auth/dependencies.pyauth-integration skill for React/Next.js auth contextAuthorization: Bearer <token> headerHTTPBearer() dependency validates and extracts user| File | Purpose |
|------|---------|
| auth/jwt.py | Token creation, encoding, secret config |
| auth/dependencies.py | FastAPI dependencies for verification and user extraction |
Set these environment variables:
JWT_SECRET_KEY: Long random string (at least 32 chars)JWT_ALGORITHM: "HS256" (default)JWT_EXPIRATION_MINUTES: 15 (recommended)Before marking complete:
auth-integration frontend skill documenteddevelopment
Apple Human Interface Guidelines for content display components. Use this skill when the user asks about charts component, collection view, image view, web view, color well, image well, activity view, lockup, data visualization, content display, displaying images, rendering web content, color pickers, or presenting collections of items in Apple apps. Also use when the user says how should I display charts, what's the best way to show images, should I use a web view, how do I build a grid of items, what component shows media, or how do I present a share sheet. Cross-references: hig-foundations for color/typography/accessibility, hig-patterns for data visualization patterns, hig-components-layout for structural containers, hig-platforms for platform-specific component behavior.
tools
Automate HelpDesk tasks via Rube MCP (Composio): list tickets, manage views, use canned responses, and configure custom fields. Always search tools first for current schemas.
testing
Expert Haskell engineer specializing in advanced type systems, pure functional design, and high-reliability software. Use PROACTIVELY for type-level programming, concurrency, and architecture guidance.
tools
GraphQL gives clients exactly the data they need - no more, no less. One endpoint, typed schema, introspection. But the flexibility that makes it powerful also makes it dangerous. Without proper controls, clients can craft queries that bring down your server. This skill covers schema design, resolvers, DataLoader for N+1 prevention, federation for microservices, and client integration with Apollo/urql. Key insight: GraphQL is a contract. The schema is the API documentation. Design it carefully.