gateway_env.py 1.3 KB

12345678910111213141516171819202122232425262728
  1. """Yuanbao env -> gateway config bridge (``PlatformEntry.env_overrides``)."""
  2. from gateway.config import Platform
  3. from gateway.platform_env import EnvCred, strip_lower
  4. ENV_ENABLE_CREDENTIALS = ("YUANBAO_APP_ID", "YUANBAO_APP_SECRET")
  5. # YUANBAO_APP_ID preferred over the legacy YUANBAO_APP_KEY.
  6. ENV_OVERRIDES = (
  7. EnvCred(
  8. Platform.YUANBAO, (("YUANBAO_APP_ID", "YUANBAO_APP_KEY"), "YUANBAO_APP_SECRET"),
  9. fixed=(("app_id", ("YUANBAO_APP_ID", "YUANBAO_APP_KEY")), ("app_secret", "YUANBAO_APP_SECRET")),
  10. optional=(
  11. ("bot_id", "YUANBAO_BOT_ID"), ("ws_url", "YUANBAO_WS_URL"),
  12. ("api_domain", "YUANBAO_API_DOMAIN"), ("route_env", "YUANBAO_ROUTE_ENV"),
  13. ("dm_policy", "YUANBAO_DM_POLICY", strip_lower), ("dm_allow_from", "YUANBAO_DM_ALLOW_FROM"),
  14. ("group_policy", "YUANBAO_GROUP_POLICY", strip_lower), ("group_allow_from", "YUANBAO_GROUP_ALLOW_FROM"),
  15. ),
  16. home="YUANBAO_HOME_CHANNEL",
  17. ),
  18. )
  19. # Authorization env names (``PlatformEntry`` fields). Core reads them from this file when the
  20. # live entry lacks them: a user plugin overriding this platform, safe mode, the plugin disabled.
  21. AUTHZ = {
  22. "allowed_users_env": "YUANBAO_ALLOWED_USERS",
  23. "allow_all_env": "YUANBAO_ALLOW_ALL_USERS",
  24. "own_policy_env": ("YUANBAO_DM_POLICY", "YUANBAO_GROUP_POLICY"),
  25. }