Registry / security / quart-auth

quart-auth

JSON →
library0.11.0pypypi✓ verified 86d ago

Quart-Auth is a Quart extension providing cookie-based authentication via secure tokens (signed, optionally encrypted). Version 0.11.0 requires Python 3.9+. It is inspired by Flask-Login with a similar API: `login_user`, `logout_user`, `@login_required`, `current_user`. Release cadence is low; latest release 2025.

pip install quart-auth
INSTALL
IMPORT
SIG · QUART-AUTH
Q
quart-auth
securitypythonv0.11.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

AuthUser
from quart_auth import AuthUser
from quart.ext.auth import AuthUser
quart_auth is a separate package, not part of Quart core.
current_user
from quart_auth import current_user
from quart import current_user
current_user is not provided by Quart itself.
login_user
from quart_auth import login_user
from quart import login_user
login_user is specific to quart-auth.
QuartAuth
from quart_auth import QuartAuth
from quart_auth import QuartAuthManager
The class is named QuartAuth, not QuartAuthManager.

Minimal Quart app with cookie authentication using quart-auth.

from quart import Quart, redirect, request, url_for from quart_auth import AuthUser, QuartAuth, current_user, login_required, login_user, logout_user app = Quart(__name__) app.secret_key = 'change-me-123' auth_manager = QuartAuth(app) @app.route('/login') async def login(): user = AuthUser(1) # Replace 1 with actual user ID login_user(user) return redirect(url_for('protected')) @app.route('/protected') @login_required async def protected(): return f'Hello {current_user.auth_id}' @app.route('/logout') async def logout(): logout_user() return 'Logged out' if __name__ == '__main__': app.run()
Debug
Known issues
breakingIn version 0.10.0, the `AuthUser` constructor signature changed. Previously you could pass arbitrary kwargs; now only `auth_id` is accepted as the first argument. If you have code like `AuthUser(1, name='Bob')` it will break.
fix
Use `AuthUser(1)` only. Store any extra user data via a separate lookup.
affects: >=0.10.0
gotcha`current_user` is not available during app startup before first request. It relies on the request context. Attempting to access it outside of a request will raise `ContextVarNotSet` or similar.
fix
Always access `current_user` inside a route handler or after confirming a request context exists.
affects: all
deprecatedThe `login_manager` attribute (e.g., `app.login_manager`) was deprecated in favor of `auth_manager` (or the returned QuartAuth instance). Direct use of `QuartAuth(app)` is the recommended pattern.
fix
Replace `app.login_manager` with the instance returned by `QuartAuth(app)`.
affects: >=0.9.0
Errors
Common errors & fixes
RuntimeError: No such config: 'QUART_AUTH_COOKIE_NAME'
Trying to set config keys that do not exist (typo or wrong name). The correct config key includes prefix 'QUART_AUTH_'.
fix
Check the config name exactly; e.g., use `app.config['QUART_AUTH_COOKIE_NAME'] = 'mycookie'`.
AttributeError: module 'quart_auth' has no attribute 'current_user'
Import incorrect: using `from quart_auth import current_user` but misspelled or imported from wrong module.
fix
Ensure the import is `from quart_auth import current_user`.
TypeError: __init__() got an unexpected keyword argument 'name'
Old code using `AuthUser(id, name='...')`; newer versions only accept positional `auth_id`.
fix
Use `AuthUser(auth_id)` only. Retrieve user details via a separate call.
Upgrade
Version history
0.11.0latest on PyPI · released Dec 26, 2024
Audit
Dependencies
quartrequiredCore framework
Agent activity
26 hits · last 30 days
node
24
OpenAI (training)
1
Resources

No resource links recorded.

quart-auth — pip install quart-auth · libregistry