Scope API sessions by session key - #42460
Closed
necoweb3 wants to merge 1 commit into
Closed
Conversation
Contributor
|
LGTM. The session-scoping logic is well-structured:
One minor note: |
necoweb3
force-pushed
the
fix/api-sessions-session-key-scope
branch
from
June 26, 2026 16:26
b86e3b5 to
9557aaa
Compare
Contributor
Author
Rebased this PR onto current `origin/main` and reran the focused session API coverage.
Validation:
```text
python -m pytest tests/gateway/test_session_api.py -q --timeout-method=thread
13 passed |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This records
X-Hermes-Session-Keyownership for API-server session resources and enforces that owner key across the/api/sessionsresource surface.Why
X-Hermes-Session-Keyis the API server's stable per-user/channel boundary for shared-key frontend deployments. The chat endpoints parsed and forwarded it to the agent, but the session resource endpoints selected sessions bysession_idonly. A caller with the same bearer token and a different session key could list, read, patch, delete, fork, or continue another keyed session if it knew thesession_id.Wrong-key requests now return 404 so the session's existence is not disclosed.
Changes
gateway_session_keyin sessionmodel_configwhen creating keyed API sessions.GET /api/sessionsby the caller's session key.GET /api/sessions/{session_id}PATCH /api/sessions/{session_id}DELETE /api/sessions/{session_id}GET /api/sessions/{session_id}/messagesPOST /api/sessions/{session_id}/forkPOST /api/sessions/{session_id}/chatPOST /api/sessions/{session_id}/chat/streamTests