Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

myfy-user

User management module for the myfy framework.

Features

  • Email/Password Authentication - Secure password hashing with argon2/bcrypt
  • OAuth Authentication - Built-in support for Google and GitHub
  • Session Management - Cookie-based sessions for web applications
  • JWT Tokens - API authentication with access/refresh tokens
  • Email Verification - Token-based email verification flow
  • Password Reset - Secure password reset via email
  • User Profiles - Customizable user profiles
  • CLI Tools - Admin commands for user management
  • Bundled Templates - DaisyUI-styled Jinja2 templates

Installation

pip install myfy-user

Or with all myfy modules:

pip install myfy[all]

Quick Start

from myfy.core import Application
from myfy.data import DataModule
from myfy.web import WebModule
from myfy.auth import AuthModule
from myfy.user import UserModule

# Create application
app = Application()

# Add required modules
app.add_module(DataModule())
app.add_module(WebModule())

# Add user module
user_module = UserModule(
    oauth_providers=["google", "github"],
    auto_create_tables=True,
)

# Integrate with AuthModule
app.add_module(AuthModule(
    authenticated_provider=user_module.get_authenticated_provider(),
))
app.add_module(user_module)

Custom User Model

Extend the BaseUser model to add custom fields:

from sqlalchemy import String
from sqlalchemy.orm import Mapped, mapped_column
from myfy.user import BaseUser, UserModule

class User(BaseUser):
    __tablename__ = "users"

    # Custom fields
    full_name: Mapped[str | None] = mapped_column(String(255))
    phone: Mapped[str | None] = mapped_column(String(20))
    organization: Mapped[str | None] = mapped_column(String(100))

# Use custom model
user_module = UserModule(user_model=User)

Configuration

Configure via environment variables:

# Required
MYFY_USER_SECRET_KEY=your-secret-key

# OAuth (optional)
MYFY_USER_OAUTH_GOOGLE_CLIENT_ID=...
MYFY_USER_OAUTH_GOOGLE_CLIENT_SECRET=...
MYFY_USER_OAUTH_GITHUB_CLIENT_ID=...
MYFY_USER_OAUTH_GITHUB_CLIENT_SECRET=...

# Sessions
MYFY_USER_SESSION_LIFETIME=604800  # 7 days
MYFY_USER_SESSION_SECURE=true

# Password requirements
MYFY_USER_PASSWORD_MIN_LENGTH=8
MYFY_USER_PASSWORD_ALGORITHM=argon2  # or bcrypt

CLI Commands

# Initialize user templates for customization
myfy user init

# Create an admin user
myfy user create-admin -e admin@example.com

# List users
myfy user list
myfy user list --admins-only

# Reset a user's password
myfy user reset-password -e user@example.com

# Deactivate/activate users
myfy user deactivate -e user@example.com
myfy user activate -e user@example.com

# Verify email manually
myfy user verify-email -e user@example.com

Routes

The module provides the following routes:

Method Path Description
GET /login Login page
POST /login Login submission
POST /logout Logout
GET /register Registration page
POST /register Registration submission
GET /oauth/{provider} OAuth redirect
GET /oauth/{provider}/callback OAuth callback
GET /forgot-password Password reset request
POST /forgot-password Send reset email
GET /reset-password/{token} Password reset page
POST /reset-password/{token} Set new password
GET /verify-email/{token} Verify email
GET /profile User profile (protected)
POST /profile Update profile

Background Tasks

When used with myfy-tasks, the module provides background tasks:

from myfy.user import (
    send_verification_email,
    send_password_reset_email,
    send_welcome_email,
    cleanup_expired_tokens,
)

# Send verification email asynchronously
await send_verification_email.send(
    user_id=user.id,
    token=token.token,
    base_url="https://myapp.com",
)

# Cleanup old tokens (run daily via scheduler)
await cleanup_expired_tokens.send(days_old=7)

License

MIT

Release files for myfy-user 0.1.2a94

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

Source distribution (sdist)

Source distribution for myfy-user 0.1.2a94
File Size Uploaded
myfy_user-0.1.2a94.tar.gz 47.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for myfy-user 0.1.2a94
File Interpreter ABI Platform
myfy_user-0.1.2a94-py3-none-any.whl Python 3 none any Details

Total release size: 103.8 kB

Release files / myfy_user-0.1.2a94.tar.gz

Download URL myfy_user-0.1.2a94.tar.gz
Size 47.7 kB
Tags Source
SHA-256 checksum
How to use checksums
ec808ea9fca57217c6b7eb2871639b638964965ba61c9c28531da79d58febf5e
BLAKE2b-256 checksum
How to use checksums
0bc425241114d630d8a5bdb0c55fa5c804ae2e689b7e5b78980e74b5075b79fe
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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 Jan 11, 2026.

Transparency log

Release files / myfy_user-0.1.2a94-py3-none-any.whl

Download URL myfy_user-0.1.2a94-py3-none-any.whl
Size 56.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
96d39ec3009441ee7ee2b46da435050fefd867658620f01381810110930e0407
BLAKE2b-256 checksum
How to use checksums
b47714785de4d0f432eff13f12225703515544198fe8c87982ae88bc146c7719
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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 Jan 11, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.2a94 This release

2 release files

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