Skip to main content

No project description provided

Project description

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

Project details


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.1.1.tar.gz (1.3 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.1.1-py3-none-any.whl (1.1 MB view details)

Uploaded Python 3

File details

Details for the file mountaineer_auth-0.1.1.tar.gz.

File metadata

  • Download URL: mountaineer_auth-0.1.1.tar.gz
  • Upload date:
  • Size: 1.3 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for mountaineer_auth-0.1.1.tar.gz
Algorithm Hash digest
SHA256 d483598151f10f736cfbeb49e866d92041245a9e364410eb109711124ce21bf0
MD5 33383617700b0f20112dbc1fd035c315
BLAKE2b-256 0af32db80ac29105a494850f028e71127d22175f670f762768b5fe5cf86060b2

See more details on using hashes here.

Provenance

The following attestation bundles were made for mountaineer_auth-0.1.1.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.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for mountaineer_auth-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5f6cd74b1c5a66ba32d1a45f0084d6d380d6891dafa77bb30848c6c9ef5e74e8
MD5 1d7a92a196e3e339d7bafdc40578857f
BLAKE2b-256 485b30b8590e47ae4a2768f9a3e336fc1cc8d0a959f0055ee5dccc710326ae71

See more details on using hashes here.

Provenance

The following attestation bundles were made for mountaineer_auth-0.1.1-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.

Supported by

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