Skip to main content

simple_module_users

Email+password user management for simple_module apps. Replaces Keycloak/Auth0 for the common case: local accounts, admin invites, password reset, optional public signup. Built on fastapi-users.

Install

pip install simple_module_users

Pre-wired into any app scaffolded with smpy new.

What it provides

  • Email + password registration, login, logout, password reset.
  • Admin invite flow — admin enters an email, recipient clicks a link, sets a password, is logged in.
  • Public signup toggle (SM_USERS_ALLOW_SIGNUP, default false).
  • Bootstrap admin via env vars (SM_USERS_BOOTSTRAP_EMAIL + SM_USERS_BOOTSTRAP_PASSWORD) — idempotent, only creates if the users table is empty.
  • smpy users create-admin CLI for ad-hoc admin creation.
  • Inertia pages for login/register/invite-accept/admin-invite.
  • Sends verification, reset and invite emails through the framework mail sender (configure the transport in the mail module).
  • Demo mode — one-click, read-only shared admin and standard user accounts on the sign-in card, for public showcase instances.

Usage

CLI:

uv run smpy users create-admin --email admin@example.com --password 'change-me'

Bootstrap-on-boot (.env):

SM_USERS_BOOTSTRAP_EMAIL=admin@example.com
SM_USERS_BOOTSTRAP_PASSWORD=change-me

Program:

from auth.web.deps import CurrentUser


@router.get("/profile")
async def profile(user: CurrentUser):
    return {"email": user.email}

Depends on

  • simple_module_core, simple_module_db, simple_module_hosting, simple_module_settings, simple_module_auth
  • fastapi-users[sqlalchemy,oauth]>=15,<16, cachetools, typer

Demo mode

For hosting a public showcase instance. Set under /admin/settings/ → Users:

demo_mode        = true
demo_admin_email = demo-admin@example.com
demo_user_email  = demo-user@example.com
demo_read_only   = true    # default — keep it on

The sign-in card grows one button per configured account — Explore as an administrator and Explore as a standard user — each posting to POST /api/users/auth/demo/{role}. Neither account's password reaches the browser. Two accounts because the admin surface is what the framework is for and the end-user app is what you build with it; a visitor can switch between them without signing out. Blank either email to offer only the other; that closes its route too, not just its button.

Both accounts are seeded (and reconciled) at boot and on every settings reload, and while demo_read_only is on, DemoReadOnlyMiddleware refuses every unsafe HTTP method from either demo session — everyone else on the instance is unaffected. A standing banner tells the visitor they are in a demo.

Full detail, including the demo_read_only = false warning, is in docs/modules/users.md.

Social sign-in (Google, GitHub, Microsoft, OIDC)

OAuth providers are configured in the admin UI at /settings/modules → Users (no environment variables). Each provider activates once its client id and secret are set; the secret is masked in the UI. Changes apply live — no restart.

Microsoft (Entra ID). Register an app in the Entra admin center and set the redirect URI to <base-url>/api/users/auth/microsoft/callback; it needs the openid, profile and email delegated permissions (Graph User.Read is not used). Sign-in is OpenID Connect with PKCE and a nonce, and the identity comes from the validated ID token. Configure under the Microsoft OAuth group:

  • oauth_microsoft_client_id, oauth_microsoft_client_secret
  • oauth_microsoft_tenant — common (any work/school or personal account, the default), organizations (work/school only), consumers (personal only), or your tenant GUID to restrict sign-in to one tenant.
  • oauth_microsoft_trust_tenant_upn — off by default. With a tenant GUID, a member account's UPN (upn claim, else preferred_username) counts as a verified email, so it links to an invited or verified local account on first sign-in. Guests (an idp claim naming another issuer, or #EXT#) stay unverified; with any other tenant value it has no effect. It trusts the tenant's admins: whoever can set a member's UPN can sign in as the local account with that address.

Microsoft sign-in without Entra. In development and testing only, oauth_microsoft_discovery_url points the Microsoft provider at a local IdP; docs/examples/keycloak-entra-realm.json is a Keycloak realm that emits Entra-shaped claims (see the users module docs).

Provisioning through SSO with signup closed. oauth_signup_providers (e.g. ["microsoft"]) lets those providers create an account on first sign-in when they proved the email, while local registration keeps following allow_signup. oauth_signup_default_role is the role those accounts get, with signup open too (never the self-signup user role); blank (the default) means none until an admin grants one, and admin is refused.

Trusted email domains. oauth_trusted_email_domains (e.g. {"microsoft": ["iiasa.ac.at"]}) makes addresses on the listed domains count as verified for that provider: microsoft (a member of a pinned tenant GUID) and oidc only. oauth_sync_profile updates full_name from the IdP on every sign-in; each link stores the IdP's subject, username and last sign-in, shown on the admin Edit user page.

Each provider's callback URL is <base-url>/api/users/auth/<provider>/callback (google, github, microsoft, oidc).

Note: the Microsoft identity email is the ID token's optional upn claim when the app registration adds it, else preferred_username: the UPN for tenant members, the home address for a guest. A pinned tenant GUID also requires the token's tid to match it.

Migrating from SM_USERS_OAUTH_* env vars

Earlier versions read provider credentials from SM_USERS_OAUTH_* environment variables. These are no longer read at runtime. Migrate existing values into the settings store once with:

uv run smpy settings import-from-env

License

MIT — see LICENSE.

Metadata

Release files for simple-module-users 0.0.46

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-users 0.0.46
File Size Uploaded Provenance Actions
simple_module_users-0.0.46.tar.gz 349.6 kB With provenance Details for simple_module_users-0.0.46.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for simple-module-users 0.0.46
File Interpreter ABI Platform Actions
simple_module_users-0.0.46-py3-none-any.whl Python 3 none any Details for simple_module_users-0.0.46-py3-none-any.whl

Total release size: 624.5 kB

Release files / simple_module_users-0.0.46.tar.gz

Download URL simple_module_users-0.0.46.tar.gz
Size 349.6 kB
Tags Source
SHA-256 checksum
How to use checksums
71e9dffdab3cd0913b03cb293fd2c770af14751bc55480c4f5b374135576d2cc
BLAKE2b-256 checksum
How to use checksums
2e4031b8a9cfd07991eef4dad443ac3ced0c1a90c82d95390c41894670da59f6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 13, 2026.

Transparency log

Release files / simple_module_users-0.0.46-py3-none-any.whl

Download URL simple_module_users-0.0.46-py3-none-any.whl
Size 274.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
92f815e22287510e61f9843bdea3ddf95143fed8a03ad4bc2e7904e80b695b8f
BLAKE2b-256 checksum
How to use checksums
6ccc59fc91c5d9960084f1993a9826401ef3d3b4eff8da1a94b53e4845afd952
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 13, 2026.

Transparency log

Security for simple-module-users 0.0.46

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

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for simple_module_users-0.0.46.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 Nov 13, 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.46 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