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.1.tar.gz (11.9 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.1-py3-none-any.whl (14.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: soorma_service_common-0.9.1.tar.gz
  • Upload date:
  • Size: 11.9 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.1.tar.gz
Algorithm Hash digest
SHA256 4354298d79741985edaa8f75ce1e28e0809edd1d1ab4bc26eca652c9efba2d45
MD5 40e0cf334bc08d5caba90be6a7310bba
BLAKE2b-256 71ad473ebbb635a29f4c24c8739b60bd5dd634580f011a4f6d6e30779a859f00

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for soorma_service_common-0.9.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1c59bddcd07ba7574fac54cbdafbbda61593d9c6f669ceeb939208ef8f7f6aa4
MD5 02fd150a913710d51709a4e4318679a9
BLAKE2b-256 3a2e25a046fc3d37aafec2400f91c58b87693fbf5eeb275f6ed91d14a5b70bb3

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