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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mountaineer_auth-0.2.1.tar.gz.
File metadata
- Download URL: mountaineer_auth-0.2.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.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fd96320c40487ae4c577c17e0521b513adf66415feec1fa82b1e0fee142de371
|
|
| MD5 |
aa5b59698841d14674ae6cf19fae8f63
|
|
| BLAKE2b-256 |
45dd3321fcefd7387a325cbf01fbd35c6cb1dc9501d61488cc1b71bef9787ae9
|
Provenance
The following attestation bundles were made for mountaineer_auth-0.2.1.tar.gz:
Publisher:
test.yml on piercefreeman/mountaineer-auth
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mountaineer_auth-0.2.1.tar.gz -
Subject digest:
fd96320c40487ae4c577c17e0521b513adf66415feec1fa82b1e0fee142de371 - Sigstore transparency entry: 1448241447
- Sigstore integration time:
-
Permalink:
piercefreeman/mountaineer-auth@091cda5d88a49721dc5e1a569517906bc9a504f8 -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/piercefreeman
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
test.yml@091cda5d88a49721dc5e1a569517906bc9a504f8 -
Trigger Event:
push
-
Statement type:
File details
Details for the file mountaineer_auth-0.2.1-py3-none-any.whl.
File metadata
- Download URL: mountaineer_auth-0.2.1-py3-none-any.whl
- Upload date:
- Size: 1.1 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c0bc4322b6a8870d45f91fc91d9c6fe6294b63d5c45bea514ee5738f8a19e62c
|
|
| MD5 |
78ec3e11e78a5659f1c586d8441606c0
|
|
| BLAKE2b-256 |
d4727b07d81e6fd159fce8ba0fb9fb2012f12bd73eec8cd76f7d62dbf0bf62e0
|
Provenance
The following attestation bundles were made for mountaineer_auth-0.2.1-py3-none-any.whl:
Publisher:
test.yml on piercefreeman/mountaineer-auth
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mountaineer_auth-0.2.1-py3-none-any.whl -
Subject digest:
c0bc4322b6a8870d45f91fc91d9c6fe6294b63d5c45bea514ee5738f8a19e62c - Sigstore transparency entry: 1448241510
- Sigstore integration time:
-
Permalink:
piercefreeman/mountaineer-auth@091cda5d88a49721dc5e1a569517906bc9a504f8 -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/piercefreeman
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
test.yml@091cda5d88a49721dc5e1a569517906bc9a504f8 -
Trigger Event:
push
-
Statement type: