From 2e3dd071a56edcd8e13ca60642d307cc37f86f8f Mon Sep 17 00:00:00 2001 From: matevip Date: Thu, 2 Jul 2026 17:51:25 +0800 Subject: [PATCH] fix(kb-open): assert session belongs to path kbId + cleanup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - requireSessionOwnership now also checks session.kbId() == path kbId (404 on mismatch), so a research session started under one KB cannot be addressed via another KB path even when the caller's key is bound to both — defense-in-depth on top of the keyId ownership check. - Drop internal "R7" / "review #446" markers from the controller Javadoc in favour of functional wording. - Import Set/Map/concurrent types and static any() instead of inline FQNs in the new kb-open research/auth tests, per code style. --- .../controller/KbOpenResearchController.java | 18 ++++++++++++------ .../kbopen/auth/KbOpenApiAuthFilterTest.java | 7 ++++--- .../KbResearchSessionRegistryTest.java | 11 +++++++---- 3 files changed, 23 insertions(+), 13 deletions(-) diff --git a/mateclaw-server/src/main/java/vip/mate/kbopen/controller/KbOpenResearchController.java b/mateclaw-server/src/main/java/vip/mate/kbopen/controller/KbOpenResearchController.java index 5be1986b..89565fe5 100644 --- a/mateclaw-server/src/main/java/vip/mate/kbopen/controller/KbOpenResearchController.java +++ b/mateclaw-server/src/main/java/vip/mate/kbopen/controller/KbOpenResearchController.java @@ -36,11 +36,11 @@ import java.util.concurrent.Executors; * pipeline) with SSE progress. The start endpoint returns a sessionId; the * caller subscribes to SSE for progress, or polls status for the final result. * - *

R7: the SSE endpoint uses {@code ?token=} query param because browser + *

The SSE endpoint uses a {@code ?token=} query param because browser * EventSource cannot set Authorization headers. The {@code KbOpenApiAuthFilter} * already falls back to query param tokens. * - *

Cost & lifecycle controls (review #446)

+ *

Cost & lifecycle controls

*