Server status ...

magogi/prod/: mgf-fastapi-0.6.6 metadata and description

Simple index Newer version available

FastAPI integration adapters for mgf-common — request-id + exception translation + lifespan + webhooks (Svix HMAC) + IpAllowlist + run_test_app + DB-session helpers (via [sqlalchemy] extra). Sibling of mgf-common under the mgf.* namespace.

author Bassam Alsanie, mgf-fastapi contributors
classifiers
  • Development Status :: 3 - Alpha
  • Framework :: FastAPI
  • Intended Audience :: Developers
  • License :: OSI Approved :: MIT License
  • Operating System :: MacOS
  • Operating System :: Microsoft :: Windows
  • Operating System :: POSIX :: Linux
  • Programming Language :: Python :: 3
  • Programming Language :: Python :: 3.11
  • Programming Language :: Python :: 3.12
  • Programming Language :: Python :: 3.13
  • Topic :: Internet :: WWW/HTTP
  • Topic :: Software Development :: Libraries
  • Typing :: Typed
description_content_type text/markdown
keywords fastapi, ip-allowlist, middleware, request-id, svix, webhooks
license MIT
license_file
  • LICENSE
project_urls
  • Homepage, https://codeberg.org/magogi-admin/mgf-fastapi
  • Issues, https://codeberg.org/magogi-admin/mgf-fastapi/issues
  • Changelog, https://codeberg.org/magogi-admin/mgf-fastapi/src/branch/main/CHANGELOG.md
requires_dist
  • fastapi>=0.110
  • mgf-common<0.46,>=0.41
  • aiosqlite>=0.20; extra == 'dev'
  • httpx>=0.27; extra == 'dev'
  • hypothesis>=6.100; extra == 'dev'
  • import-linter>=2.0; extra == 'dev'
  • mgf-livepush<0.2,>=0.1; extra == 'dev'
  • mgf-sqlalchemy<0.6,>=0.5; extra == 'dev'
  • mgf-test-supervisor<0.2,>=0.1.3; extra == 'dev'
  • mypy>=1.10; extra == 'dev'
  • pytest-asyncio>=0.23; extra == 'dev'
  • pytest-cov>=5.0; extra == 'dev'
  • pytest-timeout<3,>=2.3; extra == 'dev'
  • pytest>=8.0; extra == 'dev'
  • ruff>=0.4; extra == 'dev'
  • uvicorn>=0.30; extra == 'dev'
  • mgf-livepush<0.2,>=0.1; extra == 'livepush'
  • mgf-sqlalchemy<0.6,>=0.5; extra == 'sqlalchemy'
  • httpx>=0.27; extra == 'testing'
  • uvicorn>=0.30; extra == 'testing'
requires_python >=3.11

Because this project isn't in the mirror_whitelist, no releases from root/pypi are included.

File Tox results History
mgf_fastapi-0.6.6-py3-none-any.whl
Size
38 KB
Type
Python Wheel
Python
3

mgf-fastapi — FastAPI integration adapters for mgf-common

PyPI Python

Shape: Federation sibling of mgf-common. The current mgf-common pin window is shown in this package's PyPI metadata — sourced from pyproject.toml at release time, so this README can't go stale. (Per v2.6 DOC-01 / project-shape taxonomy. PAPER-38.)

Sibling of mgf-common under the mgf.* namespace. Houses every FastAPI-specific adapter that previously lived under mgf.common.fastapi.* — extracted at mgf-common v0.28 / mgf-fastapi v0.1 per the federation split plan.

What this provides

Submodule What
mgf.fastapi bootstrap ↔ FastAPI lifespan; RequestIdMiddleware; ExceptionTranslationMiddleware; Depends() helpers (get_app_context, get_settings, get_request_id); setup_lifespan.
mgf.fastapi.webhooks Svix-shape HMAC webhook verification (HmacWebhookVerifier, WebhookHeaderSchema, SVIX_SCHEMA, verify_request).
mgf.fastapi.security IpAllowlist FastAPI dependency with proxy-trust opt-in.
mgf.fastapi.testing run_test_app async context manager — start uvicorn for a FastAPI app on a free port; yield base URL; clean shutdown.
mgf.fastapi.exceptions HmacVerificationError(HttpUnauthorized) and other framework-domain concrete leaves. (HTTP-01 hierarchy roots stay in mgf.common.exceptions.)

Install

pip install mgf-fastapi
# Or with the test-helper extra (uvicorn + httpx for run_test_app):
pip install 'mgf-fastapi[testing]'

Pulls in mgf-common and fastapi automatically.

Quick start

from fastapi import FastAPI, Request
from mgf.fastapi import (
    ExceptionTranslationMiddleware,
    RequestIdMiddleware,
    setup_lifespan,
)
from mgf.fastapi.webhooks import HmacWebhookVerifier, verify_request

app = FastAPI(lifespan=setup_lifespan(app_name="my-service", app_version="0.1.0"))
app.add_middleware(ExceptionTranslationMiddleware)
app.add_middleware(RequestIdMiddleware)

webhook = HmacWebhookVerifier(secret=settings.webhook_secret)

@app.post("/webhooks/clerk")
async def clerk_webhook(request: Request) -> dict:
    event_id, ts = await verify_request(request, webhook)
    payload = await request.json()
    # ... process the (now-trusted) payload ...
    return {"ok": True}

Documentation

For the federation-wide engineering standards (DESIGN_PRINCIPLES, ERROR_HANDLING, SECURITY, etc.) see mgf-doc-standard/docs/standards/. This sibling inherits them by reference; the standards source-of-truth lives in mgf-common.

Conformance: L2 per mgf-doc-standard/docs/standards/. Per-rule audit ledger: docs/inprogress/MGF_STANDARDS_CONFORMANCE.md. L2 means every federation MUST rule applies, evidenced by the tracker.

Status

🚧 Experimental — every public name is experimental per AP-09. Promotion to stable happens release-by-release as consumer feedback in FEEDBACK.md converges. The 0.x window applies. Pin tightly: mgf-fastapi = ">=0.X.0,<0.Y".

Cross-references