lbedner/aegis-stack/protect-an-endpoint
Claude Code and agent skill by lbedner/aegis-stack
- community
Checking that the SKILL.md file is still in the repository.
Use when an API endpoint in this project must require an authenticated user or a specific role. Covers the auth dependencies, attaching them to a route, and the session and cookie rules.
Install
npx vskill@latest install lbedner/aegis-stack/protect-an-endpointSKILL.md
Protect an endpoint
Authentication is enforced with FastAPI dependencies from the auth service, not by inspecting sessions inside handlers. Attaching the dependency is what makes a route require a signed-in user; a route without it is public.
When to use
Use when a route must require an authenticated user, or a user with a specific role, before it runs.
Do NOT use to add the endpoint itself (see the add-api-endpoint skill) or to change the auth service internals.
Files that change
app/services/auth/deps.py: the auth dependencies (the current-user
dependency and the role dependency); reuse these rather than writing a check.
app/components/backend/api/: the endpoint module whose route you protect.
Procedure
- Write the failing test first: assert the route returns 401 without
credentials and succeeds with them. Confirm it fails for the right reason.
- Import the current-user dependency from
app/services/auth/deps.py. - Attach it to the route with
Depends(...), binding the authenticated user to
a handler parameter.
- For a role-restricted route, use the role dependency rather than inspecting
the user object by hand.
- Run the gates and fix anything red.
Gates
make check: lint, typecheck, and test.
Pitfalls
- Checking the session or cookie by hand inside a handler duplicates the auth
logic and drifts from it; depend on the auth dependency instead.
- Protection is per-route: a route without the dependency attached is public
even when other routes in the same module are protected.
- Auth state travels in the session cookie set by the auth flow; do not read or
set that cookie manually, and keep the handler logic independent of any particular frontend.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingaegis/templates/copier-aegis-project/{{ project_slug }}/.claude/skills/protect-an-endpoint/SKILL.md
Popularity
- Repository stars
- 130
- Repository forks
- 10
- 7-day trend score
- 24
Stars and forks are for the whole GitHub repository, not this skill alone. 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/lbedner/aegis-stack/protect-an-endpoint)