Skip to main content

Session-cookie authentication primitives — middleware, login/logout, redirect helpers for simple_module

Project description

simple_module_auth

Session-cookie authentication primitives for simple_module apps. Provides the SessionMiddleware wiring, login/logout helpers, and login-redirect handling used by the simple_module_users module.

Heads up: for most apps you don't install this directly — simple_module_users pulls it in and builds the email+password auth flow on top of these primitives.

Install

pip install simple_module_auth

What it provides

  • Starlette SessionMiddleware configuration reading SM_SECRET_KEY and SM_SESSION_COOKIE_* env vars.
  • current_user_id FastAPI dependency reading the signed session cookie.
  • Redirect-to-login helpers for unauthenticated requests on Inertia routes.
  • Login-required decorator / dependency for protecting routes without pulling in the heavier simple_module_users package.

Usage

from fastapi import APIRouter, Depends
from simple_module_auth import require_login

router = APIRouter()


@router.get("/me")
async def me(user_id: int = Depends(require_login)):
    return {"user_id": user_id}

Routes that need more than just "logged in" (e.g. role/permission checks) should use simple_module_permissions instead.

Depends on

  • simple_module_core, simple_module_db
  • itsdangerous

License

MIT — see LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

simple_module_auth-0.0.18.tar.gz (12.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

simple_module_auth-0.0.18-py3-none-any.whl (11.7 kB view details)

Uploaded Python 3

File details

Details for the file simple_module_auth-0.0.18.tar.gz.

File metadata

  • Download URL: simple_module_auth-0.0.18.tar.gz
  • Upload date:
  • Size: 12.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for simple_module_auth-0.0.18.tar.gz
Algorithm Hash digest
SHA256 61e894d8e6fd801eaaa997c2dadbbd5ca12a1f5dca43f9175834146c5f1197a8
MD5 83d1643593eecbca9e4ab66d60a5b079
BLAKE2b-256 39c4124c45b27accbaffc9a695d1c9682bca62cde213b41f879595aa0c41d0b5

See more details on using hashes here.

Provenance

The following attestation bundles were made for simple_module_auth-0.0.18.tar.gz:

Publisher: release.yml on antosubash/simple_module_python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file simple_module_auth-0.0.18-py3-none-any.whl.

File metadata

File hashes

Hashes for simple_module_auth-0.0.18-py3-none-any.whl
Algorithm Hash digest
SHA256 75d63bf5eb2fd2023a6cec6a254e846139dc6a9af7131774bbfb0a8f45ab29b1
MD5 ab5da8d105d205ed4de96cd6d546aa4b
BLAKE2b-256 9242e1985a655e7e21e524e9f0e02903bcbc515b257d470cd6d158c19e736c2f

See more details on using hashes here.

Provenance

The following attestation bundles were made for simple_module_auth-0.0.18-py3-none-any.whl:

Publisher: release.yml on antosubash/simple_module_python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page