jmservera/aithena/fastapi-patterns
Claude Code and agent skill by jmservera/aithena
- community
Checking that the SKILL.md file is still in the repository.
FastAPI authentication, authorization, query parameter handling, and API design patterns
Install
npx vskill@latest install jmservera/aithena/fastapi-patternsSKILL.md
The same SKILL.md was published earlier as jmservera/aithena/fastapi-patterns.
Context
Apply when building or reviewing FastAPI endpoints in aithena, particularly for authentication, authorization, cookie management, and query parameter handling. Covers the local auth system (SQLite + Argon2id + JWT + nginx).
Pattern 1: JWT Cookie SSO Across Services
Requirements: Both services share AUTH_JWT_SECRET and AUTH_COOKIE_NAME env vars.
Pattern 2: Cookie Refresh on Validate
Without refresh, expired cookies cause infinite 302 redirects via nginx auth_request.
Pattern 3: RBAC with require_role()
Pattern 4: Password Safety
- Validate BEFORE hashing: Check length (8–128 chars), uppercase, lowercase, digit
- Max length check prevents DoS: Argon2 processes entire input; 1MB password consumes significant CPU
- Rate limiting: 10 attempts per 15 minutes per IP via Redis (
login_attempts:{ip})
Pattern 5: Query Parameter Declaration
FastAPI silently ignores undeclared query parameters. Unlike Flask/Express, you must explicitly declare them.
Use `Query()` for validation:
For dynamic parameters: Use request.query_params:
Pattern 6: Testing Auth
Anti-Patterns
- ❌ Don't share JWT secret as default/fallback — mandatory env var
- ❌ Don't skip JWT exp validation — always check expiry in decode
- ❌ Don't use `logger.exception()` in auth error paths — exposes internal state
- ❌ Don't assume cookie == authenticated for admin — verify role claim
- ❌ Don't wrap `require_role()` in `Depends()` — already returns
Depends(inner) - ❌ Don't validate password after hashing — check length/complexity BEFORE Argon2
- ❌ Don't assume query params are automatically available — FastAPI requires explicit declaration
- ❌ Don't add frontend params without updating backend — 200 OK but silently ignored
- ❌ Don't use `kwargs
for query params** — FastAPI doesn't support it; userequest.query_params`
References
src/solr-search/auth.py,src/solr-search/main.pysrc/admin/src/auth.py- Issue #656 (fq_folder bug)
- v1.10.1 auth hardening
Security
- Security scanPassed, 90 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryChecking.squad/skills/fastapi-patterns/SKILL.md
Popularity
- 7-day trend score
- 0
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
[](https://verified-skill.com/skills/jmservera/aithena/fastapi-patterns)