{"id":"d7285dc7-2a93-423e-952b-5b7d448ee43d","shortId":"GA6fws","kind":"skill","title":"litestar-auth-guards","tagline":"Auto-activate for guards=, Guard, ASGIConnection, BaseRouteHandler, connection.user, PermissionDeniedException, JWT auth, OAuth2, role checks, tenant checks, or WebSocket auth. Use when implementing Litestar authentication, authorization, Guards, or permission boundaries. Not for","description":"# Litestar Auth and Guards\n\nUse this skill for authentication boundaries, authorization checks, guard composition, and user context.\n\n## Code Style Rules\n\n- Put auth and permission checks in Guards or middleware, not handler bodies.\n- Prefer Controller-level guards when a whole domain shares a policy.\n- Raise Litestar HTTP exceptions or domain exceptions consistently.\n- Keep tenant isolation explicit in guard logic and service filters.\n\n## Quick Reference\n\n- Guard patterns: [guards.md](references/guards.md)\n- Middleware user loading: [litestar-middleware](../litestar-middleware/SKILL.md)\n- Realtime auth: [litestar-realtime](../litestar-realtime/SKILL.md)\n\n<workflow>\n\n## Workflow\n\n1. Determine where identity is loaded.\n2. Add Guards at app, Controller, or route scope.\n3. Keep permission checks reusable and testable.\n4. Verify denial paths and authenticated success paths.\n\n</workflow>\n\n<guardrails>\n\n## Guardrails\n\n- Do not inline auth checks in handlers.\n- Do not make Guards perform database work repeatedly when middleware can load the user once.\n- Do not trust client-supplied tenant IDs without server-side scoping.\n- Do not use HTTP-only assumptions for WebSocket auth.\n\n</guardrails>\n\n<validation>\n\n## Validation Checkpoint\n\n- [ ] Guard scope matches the policy scope.\n- [ ] Denial paths return the expected status.\n- [ ] Handlers contain no duplicated auth branching.\n- [ ] WebSocket routes use an explicit browser-compatible auth path.\n\n</validation>\n\n<example>\n\n## Example\n\n```python\nfrom litestar.connection import ASGIConnection\nfrom litestar.exceptions import PermissionDeniedException\nfrom litestar.handlers import BaseRouteHandler\n\nasync def requires_active_user(connection: ASGIConnection, _: BaseRouteHandler) -> None:\n    if not connection.user or not connection.user.is_active:\n        raise PermissionDeniedException(\"Authentication required\")\n```\n\n</example>\n\n## References Index\n\n- [guards.md](references/guards.md)\n\n## Official References\n\n- <https://docs.litestar.dev/> - Litestar documentation\n- <https://docs.litestar.dev/latest/reference/> - Litestar API reference\n\n## Shared Styleguide Baseline\n\n- [General](../litestar-styleguide/references/general.md)\n- [Python](../litestar-styleguide/references/python.md)\n- [Litestar](../litestar-styleguide/references/litestar.md)","tags":["litestar","auth","guards","skills","litestar-org","advanced-alchemy","agent-skills","agentskills","ai-agents","claude-code-plugin","claude-code-skills","gemini-cli-extension"],"capabilities":["skill","source-litestar-org","skill-litestar-auth-guards","topic-advanced-alchemy","topic-agent-skills","topic-agentskills","topic-ai-agents","topic-claude-code-plugin","topic-claude-code-skills","topic-gemini-cli-extension","topic-htmx","topic-inertia","topic-litestar","topic-mcp","topic-python"],"categories":["litestar-skills"],"synonyms":[],"warnings":[],"endpointUrl":"https://skills.sh/litestar-org/litestar-skills/litestar-auth-guards","protocol":"skill","transport":"skills-sh","auth":{"type":"none","details":{"cli":"npx skills add litestar-org/litestar-skills","source_repo":"https://github.com/litestar-org/litestar-skills","install_from":"skills.sh"}},"qualityScore":"0.453","qualityRationale":"deterministic score 0.45 from registry signals: · indexed on github topic:agent-skills · 7 github stars · SKILL.md body (2,308 chars)","verified":false,"liveness":"unknown","lastLivenessCheck":null,"agentReviews":{"count":0,"score_avg":null,"cost_usd_avg":null,"success_rate":null,"latency_p50_ms":null,"narrative_summary":null,"summary_updated_at":null},"enrichmentModel":"deterministic:skill-github:v1","enrichmentVersion":1,"enrichedAt":"2026-05-18T19:13:53.266Z","embedding":null,"createdAt":"2026-05-18T13:20:56.464Z","updatedAt":"2026-05-18T19:13:53.266Z","lastSeenAt":"2026-05-18T19:13:53.266Z","tsv":"'/latest/reference/':270 '/litestar-middleware/skill.md':111 '/litestar-realtime/skill.md':117 '/litestar-styleguide/references/general.md':278 '/litestar-styleguide/references/litestar.md':282 '/litestar-styleguide/references/python.md':280 '1':119 '2':125 '3':134 '4':141 'activ':7,242,254 'add':126 'api':272 'app':129 'asgiconnect':11,230,245 'assumpt':191 'async':239 'auth':3,16,24,38,58,113,153,194,213,223 'authent':29,45,146,257 'author':30,47 'auto':6 'auto-activ':5 'baselin':276 'baseroutehandl':12,238,246 'bodi':68 'boundari':34,46 'branch':214 'browser':221 'browser-compat':220 'check':19,21,48,61,137,154 'checkpoint':196 'client':176 'client-suppli':175 'code':54 'compat':222 'composit':50 'connect':244 'connection.user':13,250 'connection.user.is':253 'consist':88 'contain':210 'context':53 'control':71,130 'controller-level':70 'databas':162 'def':240 'denial':143,203 'determin':120 'docs.litestar.dev':265,269 'docs.litestar.dev/latest/reference/':268 'document':267 'domain':77,86 'duplic':212 'exampl':225 'except':84,87 'expect':207 'explicit':92,219 'filter':98 'general':277 'guard':4,9,10,31,40,49,63,73,94,101,127,160,197 'guardrail':149 'guards.md':103,261 'handler':67,156,209 'http':83,189 'http-on':188 'id':179 'ident':122 'implement':27 'import':229,233,237 'index':260 'inlin':152 'isol':91 'jwt':15 'keep':89,135 'level':72 'litestar':2,28,37,82,109,115,266,271,281 'litestar-auth-guard':1 'litestar-middlewar':108 'litestar-realtim':114 'litestar.connection':228 'litestar.exceptions':232 'litestar.handlers':236 'load':107,124,168 'logic':95 'make':159 'match':199 'middlewar':65,105,110,166 'none':247 'oauth2':17 'offici':263 'path':144,148,204,224 'pattern':102 'perform':161 'permiss':33,60,136 'permissiondeniedexcept':14,234,256 'polici':80,201 'prefer':69 'put':57 'python':226,279 'quick':99 'rais':81,255 'realtim':112,116 'refer':100,259,264,273 'references/guards.md':104,262 'repeat':164 'requir':241,258 'return':205 'reusabl':138 'role':18 'rout':132,216 'rule':56 'scope':133,184,198,202 'server':182 'server-sid':181 'servic':97 'share':78,274 'side':183 'skill':43 'skill-litestar-auth-guards' 'source-litestar-org' 'status':208 'style':55 'styleguid':275 'success':147 'suppli':177 'tenant':20,90,178 'testabl':140 'topic-advanced-alchemy' 'topic-agent-skills' 'topic-agentskills' 'topic-ai-agents' 'topic-claude-code-plugin' 'topic-claude-code-skills' 'topic-gemini-cli-extension' 'topic-htmx' 'topic-inertia' 'topic-litestar' 'topic-mcp' 'topic-python' 'trust':174 'use':25,41,187,217 'user':52,106,170,243 'valid':195 'verifi':142 'websocket':23,193,215 'whole':76 'without':180 'work':163 'workflow':118","prices":[{"id":"4f9c1c37-c080-4e20-98b1-41cf92e03fe6","listingId":"d7285dc7-2a93-423e-952b-5b7d448ee43d","amountUsd":"0","unit":"free","nativeCurrency":null,"nativeAmount":null,"chain":null,"payTo":null,"paymentMethod":"skill-free","isPrimary":true,"details":{"org":"litestar-org","category":"litestar-skills","install_from":"skills.sh"},"createdAt":"2026-05-18T13:20:56.464Z"}],"sources":[{"listingId":"d7285dc7-2a93-423e-952b-5b7d448ee43d","source":"github","sourceId":"litestar-org/litestar-skills/litestar-auth-guards","sourceUrl":"https://github.com/litestar-org/litestar-skills/tree/main/skills/litestar-auth-guards","isPrimary":false,"firstSeenAt":"2026-05-18T13:20:56.464Z","lastSeenAt":"2026-05-18T19:13:53.266Z"}],"details":{"listingId":"d7285dc7-2a93-423e-952b-5b7d448ee43d","quickStartSnippet":null,"exampleRequest":null,"exampleResponse":null,"schema":null,"openapiUrl":null,"agentsTxtUrl":null,"citations":[],"useCases":[],"bestFor":[],"notFor":[],"kindDetails":{"org":"litestar-org","slug":"litestar-auth-guards","github":{"repo":"litestar-org/litestar-skills","stars":7,"topics":["advanced-alchemy","agent-skills","agentskills","ai-agents","claude-code-plugin","claude-code-skills","gemini-cli-extension","htmx","inertia","litestar","mcp","python","sqlspec"],"license":"mit","html_url":"https://github.com/litestar-org/litestar-skills","pushed_at":"2026-05-13T16:04:09Z","description":"Opinionated first-party agent skills, plugins, subagents, slash commands, and MCP servers for the Litestar framework ecosystem — publishable to Claude Code, Gemini CLI, Codex CLI, Cursor, OpenCode, and VS Code/Copilot from a single repo.","skill_md_sha":"a0a6a2467dc96b5ed39ade5091a547316772fc39","skill_md_path":"skills/litestar-auth-guards/SKILL.md","default_branch":"main","skill_tree_url":"https://github.com/litestar-org/litestar-skills/tree/main/skills/litestar-auth-guards"},"layout":"multi","source":"github","category":"litestar-skills","frontmatter":{"name":"litestar-auth-guards","description":"Auto-activate for guards=, Guard, ASGIConnection, BaseRouteHandler, connection.user, PermissionDeniedException, JWT auth, OAuth2, role checks, tenant checks, or WebSocket auth. Use when implementing Litestar authentication, authorization, Guards, or permission boundaries. Not for business validation or frontend route protection."},"skills_sh_url":"https://skills.sh/litestar-org/litestar-skills/litestar-auth-guards"},"updatedAt":"2026-05-18T19:13:53.266Z"}}