gateway_env.py 862 B

1234567891011121314151617181920212223
  1. """SMS (Twilio) env -> gateway config bridge (``PlatformEntry.env_overrides``)."""
  2. from gateway.config import GatewayConfig, Platform, PlatformConfig
  3. from gateway.platform_env import EnvCred, getenv, home_step
  4. def _api_key(config: GatewayConfig, sms_config: PlatformConfig) -> None:
  5. sms_config.api_key = getenv("TWILIO_AUTH_TOKEN")
  6. ENV_ENABLE_CREDENTIALS = ("TWILIO_ACCOUNT_SID",)
  7. ENV_OVERRIDES = (
  8. EnvCred(Platform.SMS, ("TWILIO_ACCOUNT_SID",), then=_api_key),
  9. home_step(Platform.SMS, "SMS_HOME_CHANNEL"),
  10. )
  11. # Authorization env names (``PlatformEntry`` fields). Core reads them from this file when the
  12. # live entry lacks them: a user plugin overriding this platform, safe mode, the plugin disabled.
  13. AUTHZ = {
  14. "allowed_users_env": "SMS_ALLOWED_USERS",
  15. "allow_all_env": "SMS_ALLOW_ALL_USERS",
  16. "allowlist_suppresses_pairing": True,
  17. }