gateway_env.py 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. """WeCom (bot + callback sibling) env -> gateway config bridge (``PlatformEntry.env_overrides``)."""
  2. from gateway.config import Platform
  3. from gateway.platform_env import EnvCred, int_or
  4. ENV_ENABLE_CREDENTIALS = ("WECOM_BOT_ID", "WECOM_SECRET")
  5. ENV_OVERRIDES = (
  6. EnvCred(
  7. Platform.WECOM, ("WECOM_BOT_ID", "WECOM_SECRET"),
  8. fixed=(("bot_id", "WECOM_BOT_ID"), ("secret", "WECOM_SECRET")),
  9. optional=(("websocket_url", "WECOM_WEBSOCKET_URL"),),
  10. home="WECOM_HOME_CHANNEL",
  11. ),
  12. )
  13. CALLBACK_ENV_ENABLE_CREDENTIALS = ("WECOM_CALLBACK_CORP_ID", "WECOM_CALLBACK_CORP_SECRET")
  14. CALLBACK_ENV_OVERRIDES = (
  15. EnvCred(
  16. Platform.WECOM_CALLBACK, ("WECOM_CALLBACK_CORP_ID", "WECOM_CALLBACK_CORP_SECRET"),
  17. fixed=(
  18. ("corp_id", "WECOM_CALLBACK_CORP_ID"), ("corp_secret", "WECOM_CALLBACK_CORP_SECRET"),
  19. ("agent_id", "WECOM_CALLBACK_AGENT_ID"), ("token", "WECOM_CALLBACK_TOKEN"),
  20. ("encoding_aes_key", "WECOM_CALLBACK_ENCODING_AES_KEY"),
  21. # No host default: falsy extra.host lets the adapter's dual-stack DEFAULT_HOST=None bind v4+v6.
  22. ("host", "WECOM_CALLBACK_HOST"), ("port", "WECOM_CALLBACK_PORT", "", int_or(8645)),
  23. ),
  24. ),
  25. )
  26. # Authorization env names (``PlatformEntry`` fields). Core reads them from this file when the
  27. # live entry lacks them: a user plugin overriding this platform, safe mode, the plugin disabled.
  28. AUTHZ = {
  29. "allowed_users_env": "WECOM_ALLOWED_USERS",
  30. "allow_all_env": "WECOM_ALLOW_ALL_USERS",
  31. "own_policy_env": ("WECOM_DM_POLICY", "WECOM_GROUP_POLICY"),
  32. "allowlist_suppresses_pairing": True,
  33. }
  34. CALLBACK_AUTHZ = {
  35. "allowed_users_env": "WECOM_CALLBACK_ALLOWED_USERS",
  36. "allow_all_env": "WECOM_CALLBACK_ALLOW_ALL_USERS",
  37. "allowlist_suppresses_pairing": True,
  38. }