Skip to content
GitHub

Quickstart

Terminal window
uv add lexigram-auth

The quickest way to add authentication is through AuthModule.configure():

import asyncio
from lexigram import Application
from lexigram.auth import AuthModule
from lexigram.auth.config import AuthConfig, JWTConfig
async def main():
config = AuthConfig(
secret_key="your-256-bit-secret-here-must-be-long",
token=JWTConfig(secret_key="your-256-bit-secret-here-must-be-long"),
)
async with Application.boot(
name="my-app",
modules=[AuthModule.configure(config=config)],
) as app:
print(f"App running: {app.state}")
asyncio.run(main())

When you’re wiring providers explicitly (Pattern 2), use AuthBundleProvider:

from lexigram import Application
from lexigram.auth import AuthBundleProvider
from lexigram.auth.config import AuthConfig
def create_app() -> Application:
app = Application(name="my-app")
app.add_provider(AuthBundleProvider(
config=AuthConfig(secret_key="your-secret-key"),
))
return app

For unit tests, use the in-memory stub to avoid external dependencies:

from lexigram.auth import AuthModule
# Returns a DynamicModule backed by ephemeral in-memory storage
test_module = AuthModule.stub()
  • Guide — authentication, authorization, and token management workflows
  • How-Tos — JWT, RBAC, OAuth2 recipes
  • Configuration — all configuration keys