Skip to main content

mountaineer-auth

mountaineer-auth is a opinionated login package you can use to get up and running asap with a Mountaineer webapp. It's secure and has been used in the wild for the last two years.

Each user registers with their email and password. You handle appropriate authorization on your routes to determine what user is allowed where. We handle all lifecycle: login, signup, password reset, JWT tokens, etc.

  • Beautifully designed registration and login flows
  • First-class primitive for admin users
  • Dependency injection functions to quickly validate users before they hit your routes
  • All self-hosted for fast performance on your infra

Getting Started

This guide assumes that you're using the full mountaineer ecosystem: iceaxe for database models, waymark for backend workflows, mountaineer-cloud for email sending, etc. Add the models to a file like models/auth.py:

from mountaineer_auth.models import (
    UserAuthMixin,
)
from mountaineer_auth.models import (
    VerificationState as VerificationStateBase,
)

class User(UserAuthMixin):
    pass

class VerificationState(VerificationStateBase):
    pass

Add the controllers to your app.py:

from fastapi import Request, status
from fastapi.responses import RedirectResponse

from mountaineer_auth import controllers as auth_controllers
from mountaineer_auth import emails as auth_emails
from mountaineer_auth.exceptions import UnauthorizedError

controller = AppController(...)

controller.register(auth_controllers.LoginController(post_login_redirect="/app"))
controller.register(auth_controllers.SignupController(post_signup_redirect="/app"))
controller.register(auth_controllers.LogoutController(post_logout_redirect="/"))
controller.register(auth_controllers.ForgotPasswordController())
controller.register(auth_controllers.VerifyController())

# Optional, if you want email support
controller.register(auth_emails.VerifyEmailController())
controller.register(auth_emails.ForgotPasswordEmailController())

# If an unauthorized error is thrown in runtime, redirect to the login page
async def handle_unauthorized(request: Request, exc: UnauthorizedError):
    return RedirectResponse(
        status_code=status.HTTP_307_TEMPORARY_REDIRECT,
        url=f"/auth/login?after_login={request.url}",
    )

controller.app.exception_handler(UnauthorizedError)(handle_unauthorized)

Testing

make test starts a disposable Postgres instance from docker-compose.test.yml, runs the pytest suite, and tears the database down afterwards.

Development

If you update the admin UI files, you'll need to build the artifacts for inclusion in the published library. We do this automatically when distributing through CI, so this is just when you're making changes and testing locally:

uv run build-auth

Metadata

Release files for mountaineer-auth 0.2.1

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

Source distribution (sdist)

Source distribution for mountaineer-auth 0.2.1
File Size Uploaded
mountaineer_auth-0.2.1.tar.gz 1.3 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for mountaineer-auth 0.2.1
File Interpreter ABI Platform
mountaineer_auth-0.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 2.4 MB

Release files / mountaineer_auth-0.2.1.tar.gz

Download URL mountaineer_auth-0.2.1.tar.gz
Size 1.3 MB
Tags Source
SHA-256 checksum
How to use checksums
fd96320c40487ae4c577c17e0521b513adf66415feec1fa82b1e0fee142de371
BLAKE2b-256 checksum
How to use checksums
45dd3321fcefd7387a325cbf01fbd35c6cb1dc9501d61488cc1b71bef9787ae9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 May 6, 2026.

Transparency log

Release files / mountaineer_auth-0.2.1-py3-none-any.whl

Download URL mountaineer_auth-0.2.1-py3-none-any.whl
Size 1.1 MB
Tags Python 3
SHA-256 checksum
How to use checksums
c0bc4322b6a8870d45f91fc91d9c6fe6294b63d5c45bea514ee5738f8a19e62c
BLAKE2b-256 checksum
How to use checksums
d4727b07d81e6fd159fce8ba0fb9fb2012f12bd73eec8cd76f7d62dbf0bf62e0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 May 6, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.2.1 This release

2 release files

0.2.0

2 release files

0.1.1

2 release files

0.1.0

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