Skip to Content
SPAPS is proprietary hosted SaaS. Paid access required; pre-1.0 contracts may change. Terms and access
GuidesSecure Messaging

Secure Messaging

Secure messaging is the SPAPS surface for practitioner and patient messaging workflows that should travel through the shared backend instead of app-local ad hoc endpoints. The reusable package includes a gateway abstraction, while the SPAPS app mounts the concrete secure_messages domain router.

Mental Model

Gateway Responsibilities

PieceLocationPurpose
SecureMessagingGatewaysecure_messaging.pyValidates context, builds client calls, and normalizes errors
build_secure_messaging_gatewaysecure_messaging.pyConstructs a gateway from settings and optional client injection
secure_messages_routerdomains/secure_messages/router.pyExposes the concrete SPAPS API endpoints
CurrentUser route dependencydomains/secure_messages/router.pyUnconditionally requires authenticated user identity

Example Dependency Shape

from spaps_server_quickstart.secure_messaging import build_secure_messaging_gateway # `settings` comes from the service settings dependency; `user` is the # authenticated user dependency and must not be replaced by app identity. gateway = build_secure_messaging_gateway(settings=settings, user=user)

Common Mistakes

Secure-message routes unconditionally require CurrentUser. The similarly named secure_messages_require_jwt settings projection is compatibility metadata, not a router bypass. Do not treat it as an authorization control.

  • Treating API-key application identity as a substitute for user identity.
  • Returning raw client exceptions instead of normalized gateway errors.
  • Testing against a real messaging backend instead of injecting a fake client.

Next