agentsclimarketplace

Litestar auth guards

Skill litestar-org/litestar-skills/skills/litestar-auth-guards

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.

Install
npx -y skills add litestar-org/litestar-skills --skill litestar-auth-guards

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • 13 stars13 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

What its author says it does

Copied from the file, not written here

Auto-activate for guards=, Guard, ASGIConnection, JWTAuth, JWTCookieAuth, SessionAuth, role or tenant checks, or WebSocket auth. Not for frontend route protection.

SKILL.md

2.9 KB, as published. Nobody here has run it

Litestar Auth and Guards

Use this skill for authentication boundaries, authorization checks, guard composition, and user context.

Code Style Rules

  • Put auth and permission checks in Guards or middleware, not handler bodies.
  • Prefer Controller-level guards when a whole domain shares a policy.
  • Raise Litestar HTTP exceptions or domain exceptions consistently.
  • Keep tenant isolation explicit in guard logic and service filters.
  • Let authentication middleware populate connection.user and connection.auth; use guards for authorization.

Quick Reference

<workflow>

Workflow

  1. Determine where identity is loaded.
  2. Add Guards at app, Controller, or route scope.
  3. Keep permission checks reusable and testable.
  4. Verify denial paths and authenticated success paths.
</workflow> <guardrails>

Guardrails

  • Do not inline auth checks in handlers.
  • Do not make Guards perform database work repeatedly when middleware can load the user once.
  • Do not trust client-supplied tenant IDs without server-side scoping.
  • Do not use HTTP-only assumptions for WebSocket auth.
  • Do not claim WebSocket handshakes cannot carry headers. Non-browser clients can send them; the browser WebSocket API cannot set arbitrary headers.
</guardrails> <validation>

Validation Checkpoint

  • Guard scope matches the policy scope.
  • Denial paths return the expected status.
  • Handlers contain no duplicated auth branching.
  • Browser WebSocket routes use cookies, a short-lived query token, or a first-message protocol; non-browser header auth is documented separately.
</validation> <example>

Example

from litestar.connection import ASGIConnection
from litestar.exceptions import PermissionDeniedException
from litestar.handlers import BaseRouteHandler

async def requires_active_user(connection: ASGIConnection, _: BaseRouteHandler) -> None:
    if not connection.user or not connection.user.is_active:
        raise PermissionDeniedException("Authentication required")
</example>

References Index

Official References

Shared Styleguide Baseline

Keep looking

Skills are one crate of 328,083. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.