Litestar Security
Authentication and authorization for Litestar applications.
Litestar Security connects authentication providers to Litestar's middleware, dependency injection, guards, OpenAPI schema, and WebSocket lifecycle. Use local sessions or tokens, OAuth and OIDC, Google IAP, API keys, or workload JWTs without tying your application to a database library.
Quickstart
Install the package:
pip install litestar-security
Create app.py:
from litestar import Litestar, get
from litestar.di import NamedDependency
from litestar_security import (
SecurityConfig,
SecurityContext,
SecurityPlugin,
public,
)
@get("/", auth=public(), sync_to_thread=False)
def index(security_context: NamedDependency[SecurityContext]) -> dict[str, bool]:
return {"authenticated": bool(security_context.evidence)}
app = Litestar(route_handlers=[index], plugins=[SecurityPlugin(SecurityConfig())])
Run the application:
litestar --app app:app run
Public routes must be explicit. Once an authentication provider and authorization resolver are configured, routes are protected by default and guards can enforce application permissions:
from litestar import get
from litestar_security import requires_tenant_role, required
@get(
"/tenants/{tenant_id:str}",
auth=required(),
guards=[requires_tenant_role(tenant_parameter="tenant_id", roles={"owner"})],
)
async def tenant_settings(tenant_id: str) -> dict[str, str]:
return {"tenant_id": tenant_id}
Next steps
- Read the documentation
- Choose an authentication provider
- Configure local accounts
- Run the API, team, and local-auth examples
- Browse the API reference
Litestar Security supports Python 3.10 through 3.14 and is licensed under MIT.
Metadata
Release files for litestar-security 0.7.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| litestar_security-0.7.0.tar.gz | 840.5 kB | With provenance | Details for litestar_security-0.7.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| litestar_security-0.7.0-py3-none-any.whl | Python 3 | none | any | Details for litestar_security-0.7.0-py3-none-any.whl |
Total release size: 1.2 MB
Release files / litestar_security-0.7.0.tar.gz
| Download URL | litestar_security-0.7.0.tar.gz |
|---|---|
| Size | 840.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6df77d82d997f92e5048d3e2b1d16e61ee690d2b80e88aedf38b92006b4a4797
|
|
BLAKE2b-256 checksum How to use checksums |
8019141bb0def5cc706a3f8816196747172e5729985f1765e6874bfc0bdfe440
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 2, 2026.
Transparency logRelease files / litestar_security-0.7.0-py3-none-any.whl
| Download URL | litestar_security-0.7.0-py3-none-any.whl |
|---|---|
| Size | 386.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a5b4e760397ca6d970645dc4a810ee63c760d4a414ebdbf62f12c5a9b2020680
|
|
BLAKE2b-256 checksum How to use checksums |
56c9d9ed7c2d3558a43de31a14a956ac1afcbc20910531417d0016f793d7ee71
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 2, 2026.
Transparency logSecurity for litestar-security 0.7.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for litestar_security-0.7.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 2, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.