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

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for mountaineer_auth-0.2.0.tar.gz
Algorithm Hash digest
SHA256 b3ef9e31337c206231606c776560b51bf8a6b5cd01a77957a4a0be2b9f845de4
MD5 4e164edd301e4cf9b12524ff64c6cce8
BLAKE2b-256 b47e6aaa4d8fa730766e924f5338f5e27b3c818f7fafcdd1dbed53cc757ef817

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for mountaineer_auth-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3fe8db340206bfb9c33393cd64e5b9758fe5baa167a083954c1e4ead7dc34739
MD5 a6c5d799b107264759f3b63c5c0976c2
BLAKE2b-256 46b7cf96ab61cb70407b44098ec5988b6a4eec9b1dd086dc540d5f69f3964e06

See more details on using hashes here.

Provenance

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