likkisai59/spond/authorization

Claude Code and agent skill by likkisai59/spond

Trust tier 3
  • community
Source check pending

Checking that the SKILL.md file is still in the repository.

JWT-based authentication and authorization patterns for FastAPI with token validation, user lookup, and access control

Install

npx vskill@latest install likkisai59/spond/authorization

SKILL.md

The same SKILL.md was published earlier as likkisai59/spond/authorization.

Authorization Skill

JWT Authentication Pattern

python
import jwt
from fastapi import HTTPException, Request, status, Depends
from datetime import datetime, timezone
async def check_user_authorization(request: Request):
"""Validate JWT access token, attach user to request.state."""
try:
auth_header = request.headers.get("Authorization")
if not auth_header or not auth_header.startswith("Bearer "):
raise HTTPException(
status_code=status.HTTP_401_UNAUTHORIZED,
detail="Invalid authorization header",
headers={"WWW-Authenticate": "Bearer"},
)
token = auth_header.split(" ")[1]
payload = jwt.decode(token, JWT_SECRET, algorithms=[JWT_ALGORITHM])
if payload.get("type") != "access":
raise HTTPException(status_code=401, detail="Invalid access token")
user_id = payload.get("sub")
if not user_id:
raise HTTPException(status_code=401, detail="Invalid token")
# Fetch user from database
user = await fetch_user(user_id)
if not user:
raise HTTPException(status_code=401, detail="User not found")
if not user.get("is_active", True):
raise HTTPException(status_code=403, detail="Account deactivated")
request.state.user_details = user
request.state.request_id = str(uuid.uuid4())
return user
except jwt.ExpiredSignatureError:
raise HTTPException(status_code=401, detail="Token expired")
except jwt.InvalidTokenError:
raise HTTPException(status_code=401, detail="Invalid token")
# Usage
@router.get("/protected")
async def protected_route(user: dict = Depends(check_user_authorization)):
return {"user_id": user["user_id"]}

Status Codes

  • 401 Unauthorized - Missing, invalid, or expired token
  • 403 Forbidden - Valid token but insufficient permissions or deactivated account
  • 500 Internal Server Error - Unexpected error during verification

Best Practices

  1. Always verify token type (access vs refresh)
  2. Fetch user from database to check current status
  3. Check is_active flag for account status
  4. Never log or expose token contents
  5. Use HTTPS for all authenticated requests

Security

  • Security scanPassed, 95 of 100Pattern checks on the skill's files.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

7-day trend score
5

Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/likkisai59/spond/authorization/badge)](https://verified-skill.com/skills/likkisai59/spond/authorization)

Something wrong with this skill or its page? Tell us.