fix: authorize allowlisted WhatsApp group chats - #55875
Conversation
Related: #53623 (broader WhatsApp group-authz + owner-detection PR, same |
teknium1
left a comment
There was a problem hiding this comment.
Thanks for isolating the WhatsApp group-vs-DM allowlist case; current gateway/authz_mixin.py:459-605 still denies that scenario, so the regression is valuable.
Problems
gateway/authz_mixin.py:211and:214on this PR use the defaultself.adaptersregistry withoutsource.profile. Current main deliberately resolves inbound authorization through_authorization_adapter(platform, source.profile)and fails closed for missing secondary-profile adapters (gateway/authz_mixin.py:34-59). The new early allow path must use that resolver or a secondary profile could inherit the default profile's allowed WhatsApp group.- The added test (
tests/gateway/test_config_driven_access_policy.py:292) covers only the default adapter. It does not exercise the profile-isolation path introduced on main bybb304b491.
Suggested changes
- Salvage the narrow early group-chat authorization check using
_adapter_for_source(source)and profile-aware policy lookup, then add a secondary-profile regression with differing group allowlists.
Automated hermes-sweeper review.
| if not self._adapter_enforces_own_access_policy(source.platform): | ||
| return False | ||
|
|
||
| adapters = getattr(self, "adapters", None) or {} |
There was a problem hiding this comment.
Current main resolves authorization through the source's profile-specific adapter and fails closed when that adapter is absent (_authorization_adapter). This direct default-registry lookup can authorize a secondary-profile WhatsApp event with the default profile's group allowlist; resolve from source.profile instead.
Summary
group_policy: allowlist/group_allow_fromWHATSAPP_ALLOWED_USERSno longer blocks members of an explicitly allowed groupTests
scripts/run_tests.sh tests/gateway/test_config_driven_access_policy.py tests/gateway/test_relay_upstream_authz.py tests/gateway/test_whatsapp_group_gating.py -v --tb=shortgit diff --check HEAD~1..HEAD