This commit is contained in:
董宏凯 committed 2026-08-14 12:57:04 +08:00
commit 500dab29ab
3 files changed
+57

No files matched your search

@@ -479,6 +479,9 @@ async def _authorize_weknora_api_proxy(
if read_method and tail == ["me", "invitations", "pending-count"]:
return
if read_method and tail == ["tenants", "kv", "retrieval-config"]:
return
if tail[:1] == ["knowledge-bases"]:
if len(tail) == 1:
if method == "GET":
@@ -1425,3 +1425,49 @@ async def test_weknora_iframe_proxy_blocks_other_knowledge_bases() -> None:
)
assert exc_info.value.status_code == 403
@pytest.mark.asyncio
async def test_weknora_iframe_proxy_only_reads_tenant_retrieval_config() -> None:
from app.gateway.routers import llmwiki as llmwiki_router
class FakeRequest:
headers = Headers({})
query_params = QueryParams("")
def __init__(self, method: str) -> None:
self.method = method
ctx = llmwiki_router.WeKnoraEmbedContext(
mapping_id="local-kb",
weknora_id="remote-kb",
user_id="admin-a",
is_admin=True,
can_write=True,
exp=4_102_444_800,
)
await llmwiki_router._authorize_weknora_api_proxy(
FakeRequest("GET"),
ctx,
object(),
"/api/v1/tenants/kv/retrieval-config",
b"",
"token",
)
for method, path in (
("GET", "/api/v1/tenants/kv/other-setting"),
("PUT", "/api/v1/tenants/kv/retrieval-config"),
):
with pytest.raises(HTTPException) as exc_info:
await llmwiki_router._authorize_weknora_api_proxy(
FakeRequest(method),
ctx,
object(),
path,
b"{}",
"token",
)
assert exc_info.value.status_code == 403