Skip to content

fix(feishu): adapter declares enforces_own_access_policy so gateway honors group_rules - #679

Open
hashbender wants to merge 1 commit into
mainfrom
mirror/pr-56838
Open

fix(feishu): adapter declares enforces_own_access_policy so gateway honors group_rules#679
hashbender wants to merge 1 commit into
mainfrom
mirror/pr-56838

Conversation

@hashbender

Copy link
Copy Markdown
Owner

Summary

Feishu gates DM/group access at intake via FEISHU_GROUP_POLICY + per-group group_rules.<chat_id>.allowlist (parsed from config.extra). The gateway's env-based FEISHU_ALLOWED_USERS check runs AFTER this.

Problem: when no FEISHU_ALLOWED_USERS env allowlist is configured, the gateway had no way to honor the config-driven group_rules allowlist the adapter already enforced — it default-denied every Feishu group message regardless of group_rules. This is because FeishuAdapter did not declare enforces_own_access_policy = True (unlike WeCom / Weixin / Yuanbao / QQBot / WhatsApp), so the gateway's _is_user_authorized did not trust the adapter's intake-layer decision.

Fix: add enforces_own_access_policy property returning True on FeishuAdapter. The gateway now trusts the adapter's decision when chat_type is group, so group_rules becomes sufficient at the gateway layer without requiring a parallel FEISHU_ALLOWED_USERS env allowlist.

Root cause

Two-layer gating gap:

  1. Adapter layer (_allow_group_message in plugins/platforms/feishu/adapter.py): correctly uses group_rules[chat_id].allowlist — works.
  2. Gateway layer (_is_user_authorized in gateway/authz_mixin.py): checks _adapter_enforces_own_access_policy(platform) via getattr(adapter, "enforces_own_access_policy", False). Feishu returned False → gateway skipped the trust-adapter branch → default-deny for all Feishu group messages.

Changes

  • plugins/platforms/feishu/adapter.py: add enforces_own_access_policy property (returns True) to FeishuAdapter. Mirrors WeCom / Weixin / Yuanbao / QQBot / WhatsApp.
  • tests/gateway/test_config_driven_access_policy.py: extend Feishu coverage — _OWN_POLICY_PLATFORMS, _clear_auth_env (FEISHU_ALLOWED_USERS / FEISHU_ALLOW_ALL_USERS), test_own_policy_adapters_declare_the_flag.

Verification

./venv/bin/pytest tests/gateway/test_config_driven_access_policy.py tests/gateway/test_multiplex_profile_authz.py -q
# 85 passed

Checklist

  • Patch only touches the two relevant files
  • No new core tools / model tool schema changes
  • Prompt caching unaffected (no system prompt / tool schema change)
  • Mirrors existing pattern (WeCom et al.) — no new API surface

Mirror-of: NousResearch#56838
NousResearch#56838

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant