feat(trust): [wecom]/[googlechat]/[teams] first-class trust sections (Phase 1)#1366
feat(trust): [wecom]/[googlechat]/[teams] first-class trust sections (Phase 1)#1366chaodu-agent wants to merge 2 commits into
Conversation
…(Phase 1)
Clone the [line] pattern to the three remaining gateway platforms via a
shared PlatformTrustConfig (allow_all_users/allowed_users with
{PREFIX}_ALLOW_ALL_USERS / {PREFIX}_ALLOWED_USERS env fallbacks and
deny-all default). Env prefixes follow the adapters' existing
conventions: WECOM, GOOGLE_CHAT, TEAMS.
main.rs gains a platform_trust_override helper that applies the
first-class section (or its env) over the uniform GATEWAY_* seed, and
logs the shared Phase 1 deprecation warning when an active platform is
still trust-driven by the legacy env (activity signals: WECOM_CORP_ID,
GOOGLE_CHAT_ENABLED, TEAMS_APP_ID — same as has_unified_platform_env).
Trust-only by design: platform credentials stay on the gateway env
vars. Platforms needing richer trust fields later (trusted_bot_ids for
wecom/teams per their issues) graduate to their own struct, as LINE
will for group policy.
Docs: config.toml.example, config-reference.md (combined section with
per-platform sender-ID formats), wecom.md, google-chat.md,
msteams-selfhosted.md.
Refs #1358 #1359 #1360, umbrella #1356, ADR #1291. Stacked on #1365.
7d5502f to
ddc9e5d
Compare
|
Note LGTM ✅ — Clean, well-structured Phase 1 trust sections for all remaining simple-case gateway platforms. What This PR DoesWeCom, Google Chat, and MS Teams were the last gateway platforms relying solely on the uniform How It Works
Findings
Finding Details🟢 F1: Shared
|
Self-review finding: gate_incoming runs only on the embedded/unified adapter path (process_gateway_event); the standalone-gateway WebSocket path enforces trust via [gateway].allow_all_users/allowed_users and never consults the registry. The User Trust doc sections were placed in standalone-gateway setup guides without that scoping, overselling where [wecom]/[googlechat]/[teams] (and the merged [line]) take effect. Add a mode-scoping callout to each affected doc (wecom.md, google-chat.md, msteams-selfhosted.md, line.md, config-reference.md) pointing standalone deployments at [gateway] trust until Phase 1c consolidates the two paths. Also document why the LINE override stays bespoke instead of using platform_trust_override (group-policy fields land on LineConfig next).
|
Note LGTM ✅ — Clean, well-tested per-platform trust graduation with no gaps. What This PR DoesAdds first-class How It WorksA shared Findings
What's Good (🟢)
Baseline Check
5️⃣ Three Reasons We Might Not Need This PR
|
Note
Was stacked on #1365; now rebased onto
main(ddc9e5d) after #1363/#1365 merged. Diff is standalone.What problem does this solve?
WeCom, Google Chat, and MS Teams are the last gateway platforms whose identity trust is controlled only by the uniform
GATEWAY_ALLOW_ALL_USERS/GATEWAY_ALLOWED_USERSenv vars — no per-platform granularity. This clones the[line]pattern (#1365) to all three, completing the "first-class[section]per platform" row for the simple cases in umbrella #1356.Implements the config-section + registry-wiring + deprecation tasks of #1358 (WeCom), #1359 (Google Chat), #1360 (Teams). Platform-specific
is_botderivation and deny-echo tasks on those issues remain follow-ups, as with LINE.At a Glance
Proposed Solution
config.rs— one sharedPlatformTrustConfig { allow_all_users, allowed_users }+resolve_with_env(prefix)/env_trust_present(prefix), instead of three copy-pasted structs (the duplication lesson from feat(trust): Phase 1 (slack) — L3 identity via shared gate #1363's self-review, applied proactively). Env prefixes follow each adapter's existing convention:WECOM,GOOGLE_CHAT,TEAMS. Platforms that later need richer fields (e.g.trusted_bot_idsfor WeCom/Teams) graduate to their own struct, as LINE will for group policy.main.rs— aplatform_trust_overridehelper applies the section (or its env) over the uniformGATEWAY_*seed and logs the shared Phase 1 deprecation warning when an active platform is still trust-driven by legacy env. Activity signals reusehas_unified_platform_env's exact conditions:WECOM_CORP_ID,GOOGLE_CHAT_ENABLED,TEAMS_APP_ID.config.toml.example,config-reference.md(combined[wecom]/[googlechat]/[teams]section with per-platform sender-ID formats),wecom.md,google-chat.md,msteams-selfhosted.mdUser Trust sections with deprecation callouts.Why this approach?
Backward-compatible by construction (warning only; overrides are opt-in), and identical semantics to the accepted
[telegram]/[line]shape so operators learn one pattern. The shared struct + helper means #1357 (Feishu, the remaining platform) only needs to handle its extra complexity (double-gate elimination,trusted_bot_ids), not re-implement resolution.Self-review
Reviewed with the standard SOP after opening:
has_unified_platform_env.c058cbf):gate_incomingruns only on the embedded/unified adapter path; the standalone-gateway WebSocket path enforces trust via[gateway].allow_all_users/allowed_usersand never consults the registry. The User Trust doc sections were placed in standalone-gateway setup guides without saying so. Added mode-scoping callouts to wecom.md, google-chat.md, msteams-selfhosted.md, config-reference.md — and to line.md, since the merged feat(line): first-class [line] trust section (Phase 1) #1365 docs had the same gap.LineConfiggrows group-policy fields next, so routing it throughplatform_trust_overridewould be undone by the roadmap.Validation
At
ddc9e5d(macOS arm64, rebased onto main6cf869d; full suite re-run post-rebase — 660 passed, 1 known pre-existing failure):cargo clippy --workspace --all-features -- -D warnings— cleancargo clippy --workspace -- -D warnings(default features) — cleancargo check --features unified(wecom/googlechat/teams features on) — passcargo check -p openab-core --no-default-features— passcargo test -p openab-core --all-features— 658 passed, 1 failed:secrets::tests::resolve_exec_nonzero_exit(known pre-existing macOS-only failure, also fails on unmodifiedmain)platform_trust_sections_parse_from_toml,platform_trust_resolve_all_scenarios)rustfmt --check— no new drift (config.rs 0→0 after fixing one introduced diff, main.rs 4→4)Tests
platform_trust_sections_parse_from_toml— all three sections parse; absent sections →Noneplatform_trust_resolve_all_scenarios— seven env-resolution scenarios in one env-race-safe test fn (same pattern asline_resolve_all_scenarios), including a prefix-independence scenario (WECOM env must not bleed into TEAMS)Refs #1358 #1359 #1360 (config-section/registry/deprecation tasks —
is_botderivation and deny-echo remain), umbrella #1356, ADR #1291.