duck.contrib.auth

Duck’s built-in authentication helpers.

Provides session and JWT-based login, logout, and credential verification that work directly on Duck’s request object.

Sync usage::

from duck.contrib.auth import login, logout, authenticate
from duck.contrib.auth.exceptions import AuthenticationError

# Sync
try:
    user = authenticate(request, "brian@example.com", "secret")
except AuthenticationError:
    user = None

if user:
    login(request, user)

# Async
try:
    user = await async_authenticate(request, "brian@example.com", "secret")
except AuthenticationError:
    user = None

if user:
    await async_login(request, user)

Submodules

Package Contents

Data

__all__

API

duck.contrib.auth.__all__

[‘authenticate’, ‘login’, ‘logout’, ‘get_user_id’, ‘get_user_from_session’, ‘get_user_from_jwt’, ‘as…