Skip to main content

simple_module_auth

Pluggable authentication core for simple_module apps. Owns the stable public contracts every other module imports — UserContext, the AuthProvider protocol, the PrincipalResolver chain, and the get_current_user / CurrentUser / require_permission dependencies — plus the AuthMiddleware that resolves the current principal on every request.

Heads up: for most apps you don't install this directly — an auth-provider module (simple_module_users for email+password, simple_module_keycloak for OIDC) pulls it in and registers itself on app.state.auth.auth_provider.

Install

pip install simple_module_auth

What it provides

  • UserContext — the request-scoped principal (id, name, email, roles).
  • AuthProvider protocol — the swappable-backend contract (resolve_user, get_login_url, get_logout_url, get_public_paths, is_bearer_request); exactly one provider module registers an implementation on app.state.auth.auth_provider.
  • PrincipalResolver chain — async (Request) -> UserContext | None callables apps append to app.state.auth.principal_resolvers (e.g. PAT/bearer-token or API-key auth), consulted after the session path.
  • AuthMiddleware — delegates to the provider + resolver chain on every request and populates the request principal.
  • get_current_user / CurrentUser dependency and the require_permission(*permissions) dependency factory.
  • Anonymous-access is declared via the framework's method-aware register_public_routes hook (with the SM_AUTH_PUBLIC_PATHS host-level escape hatch).

Usage

from fastapi import APIRouter

from auth.deps import CurrentUser

router = APIRouter()


@router.get("/me")
async def me(user: CurrentUser):
    return {"user_id": user.id, "email": user.email}

Routes that need a specific permission use the require_permission(...) dependency factory:

from fastapi import Depends

from auth.deps import require_permission


@router.post("/", dependencies=[Depends(require_permission("products.create"))])
async def create_product(): ...

Depends on

  • simple_module_core, simple_module_db
  • itsdangerous

License

MIT — see LICENSE.

Metadata

Release files for simple-module-auth 0.0.37

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for simple-module-auth 0.0.37
File Size Uploaded Provenance
simple_module_auth-0.0.37.tar.gz 20.5 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for simple-module-auth 0.0.37
File Interpreter ABI Platform
simple_module_auth-0.0.37-py3-none-any.whl Python 3 none any Details

Total release size: 37.8 kB

Release files / simple_module_auth-0.0.37.tar.gz

Download URL simple_module_auth-0.0.37.tar.gz
Size 20.5 kB
Tags Source
SHA-256 checksum
How to use checksums
9d94179857ebf0f8235001f9c1f5ce6120b9aa96def7a834f4aaaa8b69b9ddf2
BLAKE2b-256 checksum
How to use checksums
04cd70aae45cef864ca040b69a5fdb983bf7ac3e5c66de71a69890c8b4acf21d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 19, 2026.

Transparency log

Release files / simple_module_auth-0.0.37-py3-none-any.whl

Download URL simple_module_auth-0.0.37-py3-none-any.whl
Size 17.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c923836ee29f2244624682c91b7f26e421e9f0d88940969d63bb4f06234b064a
BLAKE2b-256 checksum
How to use checksums
b49f679ba54a9256d223a5ceeedcf9fe26071a1e10123ec03def3334ab36262b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 19, 2026.

Transparency log

Security for simple-module-auth 0.0.37

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for simple_module_auth-0.0.37.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 19, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.37 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page