Skip to main content

Reusable authentication core and FastAPI/SQLAlchemy adapters for Orcestr applications.

Project description

English · Русский

Orcestr banner

orcestr-auth

PyPI Python License: MPL 2.0

Python authentication core and FastAPI/SQLAlchemy adapters for the Orcestr ecosystem.

The application keeps its real user model and product lifecycle. The package owns password, token, session, cookie, recovery, OAuth and WebSocket authentication mechanics.

Install

pip install "orcestr-auth[all]"

Optional groups:

Extra Includes
fastapi dependencies, cookie/CSRF flow and router factory
sqlalchemy auth models, direct user repository and Alembic operations
oauth GitHub, Google and Yandex provider clients
all every first-party adapter

Main APIs

Import Purpose
orcestr_auth config, password helpers, token codec and extension ports
orcestr_auth.sqlalchemy create_auth_models, UserFieldMap, user repository
orcestr_auth.services sessions, verification/reset codes and WebSocket tickets
orcestr_auth.oauth optional provider clients and normalized profiles
orcestr_auth.fastapi auth dependencies, redirect policy and router factory
orcestr_auth.migrations versioned Alembic operations for auth-owned schema

SQLAlchemy Wiring

Attach auth tables to the application's registry and real user primary key:

from orcestr_auth.sqlalchemy import UserFieldMap, create_auth_models

auth_models = create_auth_models(
    registry=Base.registry,
    user_model=UserORM,
)

user_fields = UserFieldMap(
    id=UserORM.id,
    username=UserORM.username,
    email=UserORM.email,
    password_hash=UserORM.password_hash,
    is_active=UserORM.is_active,
    email_verified_at=UserORM.email_verified_at,
)

This creates direct indexed queries and real foreign keys. It does not create a second user table and does not use runtime reflection.

FastAPI Wiring

from orcestr_auth.fastapi import create_auth_dependencies, create_auth_router

auth_dependencies = create_auth_dependencies(
    config=auth_config,
    session_dependency=get_control_db_session,
    user_model=UserORM,
    user_fields=user_fields,
    models=auth_models,
)

router = create_auth_router(
    config=auth_config,
    application_dependency=get_auth_http_application,
    current_user_dependency=auth_dependencies.current_user,
    register_model=RegisterRequest,
    user_response_model=UserRead,
)

The consumer implements the small AuthHttpApplication boundary for product-specific work: user creation, legal acceptance, tenant bootstrap, email delivery, audit and rate limits. Standard endpoints, cookies and token responses remain library-owned.

Security Model

  • browser tokens live in HttpOnly cookies and never appear in browser auth JSON;
  • cookie mutations require the configured CSRF header;
  • refresh tokens are opaque, hashed, rotated and replay-protected;
  • access JWTs validate issuer, audience, expiry, type, JTI and server session state;
  • recovery codes are hashed, expiring, attempt-limited and one-time;
  • OAuth validates redirects and supports state/PKCE without implicit account linking;
  • WebSocket access uses short-lived one-time tickets.

See security invariants and architecture boundaries.

Development

uv sync --frozen
uv run pytest -q
uv build

Ecosystem

License

Licensed under the Mozilla Public License 2.0. Commercial use is permitted; see the repository NOTICE and trademark policy.

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

orcestr_auth-0.2.0.tar.gz (28.3 kB view details)

Uploaded Source

Built Distribution

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

orcestr_auth-0.2.0-py3-none-any.whl (30.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: orcestr_auth-0.2.0.tar.gz
  • Upload date:
  • Size: 28.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for orcestr_auth-0.2.0.tar.gz
Algorithm Hash digest
SHA256 f199ac0fb0422d8c1ec4deee70b819163aeeb0bda8d1821bb259ae0e3dcdae25
MD5 c4ae47dd9441cd6107d732f3d771a872
BLAKE2b-256 2eaf2accd4625dace617b51c664b137b856ad25bdab4fffc4b77ca00002b5bfc

See more details on using hashes here.

File details

Details for the file orcestr_auth-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: orcestr_auth-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 30.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for orcestr_auth-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d5bc639d91c08abecfa24606ed37273880f9e7c9963d5a192a2403ea066541a4
MD5 5a8d2fba29f8860de4b482fb3041f4e2
BLAKE2b-256 db519e655a063e0e40ee7c1320007c7f5a0887f9e687b62689839b8c448adaeb

See more details on using hashes here.

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