mirror of
https://gitee.com/mateos/mateclaw.git
synced 2026-09-13 19:23:42 +08:00
Add per-visitor session management for the WebChat Web/API access mode: list a visitor's conversation threads, fetch a thread's messages, and delete a thread. Authorization: visitorId is a client-asserted request param, so it cannot be trusted on its own — deriving conversationId from it and then checking ownership against it is tautological (any caller passes). Instead, /stream issues a per-visitor token = HMAC-SHA256(jwtSecret, channelId:visitorId), returned in the meta event; the management endpoints require it back via the X-MC-Visitor-Token header and verify it in constant time. The signing secret is server-only (unlike the public channel API key) and the channelId in the payload makes tokens non-portable across channels. Includes regression tests for token issuance/verification semantics (forged visitorId rejected, cross-visitor and cross-channel tokens rejected, tampered tokens rejected). |
||
|---|---|---|
| .. | ||
| WebChatChannelAdapter.java | ||
| WebChatController.java | ||