Skip to main content
Pre-release

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

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

Download files

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

Source Distribution

mountaineer_auth-0.3.0.dev1.tar.gz (2.9 MB view details)

Uploaded Source

Built Distribution

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

mountaineer_auth-0.3.0.dev1-py3-none-any.whl (2.7 MB view details)

Uploaded Python 3

File details

Details for the file mountaineer_auth-0.3.0.dev1.tar.gz.

File metadata

  • Download URL: mountaineer_auth-0.3.0.dev1.tar.gz
  • Upload date:
  • Size: 2.9 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for mountaineer_auth-0.3.0.dev1.tar.gz
Algorithm Hash digest
SHA256 d7d69a9b504df68b5fb6b1860318a123a0e65602e382f3c77b7bbb3079bd329d
MD5 0a01f17ed15c8b120b457519cd28a711
BLAKE2b-256 f1badbb8cb8318c0db5b051d79317aeaf42b0da5523a2be3f2a8a00d42b84b19

See more details on using hashes here.

Provenance

The following attestation bundles were made for mountaineer_auth-0.3.0.dev1.tar.gz:

Publisher: test.yml on piercefreeman/mountaineer-auth

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

File details

Details for the file mountaineer_auth-0.3.0.dev1-py3-none-any.whl.

File metadata

File hashes

Hashes for mountaineer_auth-0.3.0.dev1-py3-none-any.whl
Algorithm Hash digest
SHA256 cbb697c008e30a78d3e8ab34761ab8d872632081c05c76e031bfb9b788210c1b
MD5 42ad5f8b0f45dee3269bed804f838547
BLAKE2b-256 8f587f4d1200be67acd5fd0bf93643baa220aaac9e910523e3063d5e38712f30

See more details on using hashes here.

Provenance

The following attestation bundles were made for mountaineer_auth-0.3.0.dev1-py3-none-any.whl:

Publisher: test.yml on piercefreeman/mountaineer-auth

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

Release history Release notifications | RSS feed

This release

0.3.0.dev1 This release

2 files

0.2.1

2 files

0.2.0

2 files

0.1.1

2 files

0.1.0

2 files

Supported by

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