fix(feishu): adapter declares enforces_own_access_policy so gateway honors group_rules - #56838
Open
shutcode wants to merge 1 commit into
Open
fix(feishu): adapter declares enforces_own_access_policy so gateway honors group_rules#56838shutcode wants to merge 1 commit into
shutcode wants to merge 1 commit into
Conversation
…onors group_rules 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; when no 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. Add enforces_own_access_policy = True on FeishuAdapter, mirroring WeCom / Weixin / Yuanbao / QQBot / WhatsApp. The gateway now trusts the adapter's intake-layer decision when the chat_type is group, so group_rules becomes sufficient at the gateway layer without requiring a parallel FEISHU_ALLOWED_USERS env allowlist. Tests: extend test_config_driven_access_policy.py to cover Feishu -- _OWN_POLICY_PLATFORMS, _clear_auth_env (FEISHU_ALLOWED_USERS / FEISHU_ALLOW_ALL_USERS), and test_own_policy_adapters_declare_the_flag.
Collaborator
Duplicate of #37916 — identical fix: adds the |
4 tasks
Contributor
|
Thanks for pursuing the Feishu two-layer admission gap; it is present on current main. Problems
Suggested changes
Automated hermes-sweeper review. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Feishu gates DM/group access at intake via
FEISHU_GROUP_POLICY+ per-groupgroup_rules.<chat_id>.allowlist(parsed fromconfig.extra). The gateway's env-basedFEISHU_ALLOWED_USERScheck runs AFTER this.Problem: when no
FEISHU_ALLOWED_USERSenv allowlist is configured, the gateway had no way to honor the config-drivengroup_rulesallowlist the adapter already enforced — it default-denied every Feishu group message regardless ofgroup_rules. This is becauseFeishuAdapterdid not declareenforces_own_access_policy = True(unlike WeCom / Weixin / Yuanbao / QQBot / WhatsApp), so the gateway's_is_user_authorizeddid not trust the adapter's intake-layer decision.Fix: add
enforces_own_access_policyproperty returningTrueonFeishuAdapter. The gateway now trusts the adapter's decision whenchat_typeis group, sogroup_rulesbecomes sufficient at the gateway layer without requiring a parallelFEISHU_ALLOWED_USERSenv allowlist.Root cause
Two-layer gating gap:
_allow_group_messageinplugins/platforms/feishu/adapter.py): correctly usesgroup_rules[chat_id].allowlist— works._is_user_authorizedingateway/authz_mixin.py): checks_adapter_enforces_own_access_policy(platform)viagetattr(adapter, "enforces_own_access_policy", False). Feishu returnedFalse→ gateway skipped the trust-adapter branch → default-deny for all Feishu group messages.Changes
plugins/platforms/feishu/adapter.py: addenforces_own_access_policyproperty (returnsTrue) toFeishuAdapter. 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
Checklist