This directory contains examples demonstrating the extended features of Quart-Auth.
Complete demonstration of storing additional user data securely in authentication cookies.
Features shown:
- Creating users with custom data (
create_user_with_data) - Storing complex data structures (preferences, metadata, etc.)
- Accessing user data via
current_user.get() - Role-based access control using stored data
- orjson optimization (when available)
Run the demo:
python examples/extended_auth_demo.pyThen visit http://localhost:5000 and try:
/login/admin- Login as admin with full permissions/login/john- Login as regular user/profile- View all stored user data/admin-only- Admin-only endpoint using role data/logout- Logout
All user data is stored in cryptographically signed cookies - users cannot read or modify the data.
Store nested objects, arrays, and any JSON-serializable data:
user = create_user_with_data(
auth_id="user_123",
username="john",
preferences={"theme": "dark"},
metadata={"departments": ["IT", "Security"]}
)@login_required
async def some_route():
username = current_user.get("username")
role = current_user.get("role")
all_data = current_user.user_dataUses orjson automatically if installed for better JSON serialization performance.
pip install git+https://github.com/pastanetwork/quart-auth.git
pip install orjson # Optional, for better performance