Add production authorization and delivery adapters
All checks were successful
CI Smoke / host-smoke (push) Successful in 0s
CI Smoke / container-smoke (push) Successful in 1s

This commit is contained in:
tegwick 2026-08-09 01:53:30 +02:00
parent c0da589dbe
commit 292e7e0e3e
5 changed files with 252 additions and 4 deletions

View file

@ -6,7 +6,8 @@ import os
from wsgiref.simple_server import make_server
from user_engine.adapters import (
LocalAuthorizationCheckPort,
FlexAuthHTTPAdapter,
HTTPOutboxDeliveryAdapter,
PostgresUserEngineStore,
VerifiedIdentityClaimsAdapter,
HTTPIdentityProvisioningAdapter,
@ -20,8 +21,7 @@ from user_engine.web import PortalApplication
def create_application() -> PortalApplication:
"""Assemble the runtime from secret-backed environment references.
The local authorization adapter is an explicit pre-production bridge. A
flex-auth HTTP adapter must replace it before the production gate.
Production authorization and delivery are fail-closed HTTP boundaries.
"""
try:
@ -38,7 +38,10 @@ def create_application() -> PortalApplication:
expected_issuer=_required("USER_ENGINE_OIDC_ISSUER"),
expected_audience=_required("USER_ENGINE_OIDC_AUDIENCE"),
),
authorization=LocalAuthorizationCheckPort(),
authorization=FlexAuthHTTPAdapter(
base_url=_required("USER_ENGINE_FLEX_AUTH_URL"),
timeout_seconds=float(os.environ.get("USER_ENGINE_FLEX_AUTH_TIMEOUT", "3")),
),
)
tenant_management = None
if os.environ.get("USER_ENGINE_TENANT_MANAGEMENT_URL"):
@ -46,6 +49,12 @@ def create_application() -> PortalApplication:
base_url=_required("USER_ENGINE_TENANT_MANAGEMENT_URL"),
bearer_token=_required("USER_ENGINE_TENANT_MANAGEMENT_TOKEN"),
)
outbox_delivery = HTTPOutboxDeliveryAdapter(
event_url=_required("USER_ENGINE_EVENT_URL"),
mail_url=os.environ.get("USER_ENGINE_MAIL_URL"),
bearer_token=_required("USER_ENGINE_DELIVERY_TOKEN"),
timeout_seconds=float(os.environ.get("USER_ENGINE_DELIVERY_TIMEOUT", "5")),
)
return PortalApplication(
service,
trusted_proxy_secret=_required("USER_ENGINE_PROXY_SECRET"),
@ -64,6 +73,7 @@ def create_application() -> PortalApplication:
bearer_token=_required("USER_ENGINE_PROVISIONING_TOKEN"),
),
tenant_management=tenant_management,
outbox_delivery=outbox_delivery,
)