litestar-security

Configure Litestar authentication, authorization, and secret handling for endpoints.

7|1|Updated Mar 2, 2026
One-click install
npx skills add https://github.com/alti3/litestar-skills --skill litestar-security
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: litestar-security
Source: https://github.com/alti3/litestar-skills/tree/main/plugins/litestar/skills/litestar-security
Command: npx skills add https://github.com/alti3/litestar-skills --skill litestar-security

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This skill provides a structured approach to securing Litestar services by combining authentication, authorization, and secret management patterns. It helps teams enforce consistent security contracts across endpoints, reduce misconfigurations, and improve auditable controls.

Core Features & Use Cases

  • Defense-in-depth with configurable authentication backends (JWTAuth, SessionAuth, etc.)
  • Guard-based authorization and per-route access control
  • Endpoint inclusion/exclusion rules to precisely protect sensitive routes
  • Safe secret handling with SecretString / SecretBytes to avoid leaking credentials
  • Practical patterns and references for common security scenarios

Quick Start

Configure Litestar with a security backend and guard rules to protect sensitive endpoints.

Frequently Asked Questions about litestar-security

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I configure JWT authentication in a Litestar API?

Configure JWT authentication in Litestar by integrating JWTAuth backends to validate tokens and enforce deterministic 401 responses for unauthorized access. This Skill provides structured patterns for setting up backends with defense-in-depth across REST and WebSocket endpoints.

How do I implement route-level authorization guards in Litestar?

Implement route-level authorization guards in Litestar by applying configurable guard rules with endpoint inclusion and exclusion patterns to protect sensitive routes. This enforces deterministic 403 responses for forbidden access attempts across REST and WebSocket endpoints.

Does Litestar support SessionAuth and JWTAuth for securing REST and WebSocket endpoints?

Yes, Litestar supports securing both REST and WebSocket endpoints using configurable authentication backends like SessionAuth and JWTAuth. This Skill integrates these backends to enforce consistent security contracts and deterministic 401 or 403 responses across services.

What is the best way to handle API secrets and credentials in Litestar?

Handle API secrets in Litestar using SecretString and SecretBytes types to prevent credential leaking in logs or responses. This Skill provides safe secret management patterns integrated with built-in authentication backends to maintain defense-in-depth.

How do I exclude specific public endpoints from authentication in Litestar?

Exclude specific public endpoints from authentication in Litestar by configuring endpoint inclusion and exclusion rules within your security backend. This allows precise protection of sensitive routes while keeping public routes accessible without token validation.