Skip to main content
Yanked

This release has been yanked by its maintainers, and will be ignored by installers, except when explicitly specified.
Consider using release 0.3.3 instead.

blenx-auth

Reusable authentication library for FastAPI applications.

Status: Beta. Open for feedback.

Features

  • JWT-based access and refresh token rotation
  • Email verification and password reset flows
  • Google OIDC OAuth client
  • Argon2id password hashing
  • Account lockout after repeated failures
  • Role / permission guards
  • Protocol-based repository contracts (SQLAlchemy + Beanie/MongoDB backends included)
  • Framework-agnostic core (no FastAPI required to use services)

Installation

# Core — no web framework dependency
pip install blenx-auth

# With FastAPI integration layer (pulls the SQLAlchemy backend too)
pip install blenx-auth[fastapi]

# With the SQLAlchemy backend only (DB driver is your choice)
pip install blenx-auth[sqlalchemy]

# With the Beanie (MongoDB) adapter
pip install blenx-auth[beanie]

Structure

src/blenx_auth/
├── __init__.py
├── core/                   # Framework- and storage-free business core
│   ├── constants.py        # Security invariants / enums
│   ├── exceptions.py       # Domain exceptions
│   ├── dto.py              # Plain data objects crossing the ports
│   ├── ports.py            # Repository + email-sender protocols
│   ├── email.py            # NullEmailSender + get_email_sender factory
│   ├── password.py         # Argon2id hashing + policy
│   ├── jwt.py              # TokenService
│   ├── schemas.py          # Pydantic wire models (FastAPI adapter)
│   ├── settings.py         # AuthSettings protocol (pure Python)
│   └── services/           # AuthenticationService, EmailVerificationService,
│                           # PasswordResetService
├── sqlalchemy/             # SQLAlchemy (PostgreSQL) adapter — default backend
│   ├── base.py             # AuthBase + UserId (uuid)
│   ├── models.py           # User / RefreshToken / OAuthAccount ORM models
│   ├── repositories.py     # SQLAlchemy*Repository protocol implementations
│   └── session.py          # create_session_factory(...) helper
├── beanie/                 # Beanie (MongoDB) adapter — optional [beanie]
│   ├── models.py           # User / RefreshToken / OAuthAccount Documents
│   ├── bootstrap.py        # init_beanie_db(...) helper
│   └── repositories.py     # Beanie*Repository protocol implementations
└── fastapi/                # Optional FastAPI integration subpackage [fastapi]
    ├── __init__.py
    ├── composition.py      # SQLAlchemyAuth / BeanieAuth composition roots
    ├── current_user.py     # Current-user dependency factory
    ├── exception_handlers.py  # auth_error_handler
    ├── google_oauth.py     # Google OIDC client (pure httpx-oauth)
    ├── permissions.py      # make_permission_guards(...) dependency factories
    └── routers/            # make_auth_router / make_users_router / make_oauth_router

The host application wire-up is a composition root: pick a backend, bind the services, and hand the result to the router factories.

from blenx_auth.fastapi import SQLAlchemyAuth, make_auth_router, make_users_router

auth = SQLAlchemyAuth(settings=settings, session_factory=session_factory)
app.include_router(make_auth_router(auth))
app.include_router(make_users_router(auth))

Examples

See the examples/ directory for:

  • standalone.py — wiring core services to in-memory fakes (no DB, no web framework)
  • sqlalchemy_example.py — using the SQLAlchemy repositories
  • beanie_example.py — using the Beanie (MongoDB) repositories

License

MIT

Metadata

Release files for blenx-auth 0.3.0

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

Source distribution (sdist)

Source distribution for blenx-auth 0.3.0
File Size Uploaded
blenx_auth-0.3.0.tar.gz 57.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for blenx-auth 0.3.0
File Interpreter ABI Platform
blenx_auth-0.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 107.1 kB

Release files / blenx_auth-0.3.0.tar.gz

Download URL blenx_auth-0.3.0.tar.gz
Size 57.1 kB
Tags Source
SHA-256 checksum
How to use checksums
f69f6982e2cf8ba63c1a35b1ec9ea3130680068b11961de5a771b29aecb594f8
BLAKE2b-256 checksum
How to use checksums
14c7d8bdaa3e5952d5d20adec90617bf33958a269f1fdd5ca4ec95205620d881
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.8.4

Release files / blenx_auth-0.3.0-py3-none-any.whl

Download URL blenx_auth-0.3.0-py3-none-any.whl
Size 50.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ae3fda9076df6685ce5a662bb269ebbb1f7d489ce7295012f02443bf3d6bd417
BLAKE2b-256 checksum
How to use checksums
839cfa2a5862ed7dfe918e014e07d453d9c874cfc155ca8ca6760afe80253070
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.8.4

Release history Release notifications | RSS feed

0.3.3

2 release files

0.3.2

2 release files

This release

0.3.0 This release

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