Skip to main content

Shared FastAPI/Starlette infrastructure for Soorma backend services

Project description

soorma-service-common

Shared FastAPI/Starlette infrastructure library for Soorma backend services.

Provides three cross-cutting concerns for all services (Memory, Tracker, Registry, Event Service):

  1. Identity extractionTenancyMiddleware validates bearer tokens and projects platform-tenant, service-tenant, and service-user identity into request.state on secured requests.
  2. RLS activationcreate_get_tenanted_db factory produces a FastAPI dependency that calls PostgreSQL set_config for all three session variables (transaction-scoped) before yielding the DB session, activating Row-Level Security policies.
  3. GDPR deletion contractPlatformTenantDataDeletion abstract base class defines the erasure interface; concrete implementations live in each service.

Usage

# In your service's core/dependencies.py
from soorma_service_common import (
    create_get_tenanted_db,
    create_get_tenant_context,
)
from my_service.core.database import get_db

get_tenanted_db = create_get_tenanted_db(get_db)
get_tenant_context = create_get_tenant_context(get_tenanted_db)
# In your service's main.py
from soorma_service_common import TenancyMiddleware

app.add_middleware(TenancyMiddleware)
# In your route handlers
from my_service.core.dependencies import get_tenant_context
from soorma_service_common import TenantContext

@router.post("/items")
async def create_item(payload: ItemCreate, ctx: TenantContext = Depends(get_tenant_context)):
    return await service.create(ctx.db, ctx.platform_tenant_id, ctx.service_tenant_id, ctx.service_user_id, payload)

Constraints

  • MUST NOT be imported by soorma-common or sdk/python — contains FastAPI/Starlette dependencies incompatible with SDK clients.
  • platform_tenant_id flows from validated request identity or Event Service injection — never as a per-call API parameter.

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

soorma_service_common-0.9.0.tar.gz (11.8 kB view details)

Uploaded Source

Built Distribution

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

soorma_service_common-0.9.0-py3-none-any.whl (14.3 kB view details)

Uploaded Python 3

File details

Details for the file soorma_service_common-0.9.0.tar.gz.

File metadata

  • Download URL: soorma_service_common-0.9.0.tar.gz
  • Upload date:
  • Size: 11.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for soorma_service_common-0.9.0.tar.gz
Algorithm Hash digest
SHA256 969c655b69dde8de3547edbaec6395a45cd6389a952becdeaebb04dcee6d2750
MD5 3076bfbeb179ea77a1a39bb2169efaf4
BLAKE2b-256 b6553022051b855f1e8becec9f4dd38e6374b8fc6241195ca04cd774b8eaaa79

See more details on using hashes here.

File details

Details for the file soorma_service_common-0.9.0-py3-none-any.whl.

File metadata

File hashes

Hashes for soorma_service_common-0.9.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e45d88171721fa61bfc4ed790e2fa3f51e3d92f2a67e3a436cb270aeaac71f1b
MD5 27c1deeb491fdfbfb936076999866cff
BLAKE2b-256 d56f3f499642b1326866f9339c2b3901eefeb240017341ae9b50a792a8b734ed

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