allow channel-token ws subscriptions within their own namespace#241
allow channel-token ws subscriptions within their own namespace#241ayush-that wants to merge 2 commits into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughChannel-authenticated WebSocket subscriptions now bypass participant verification for sessions within the configured channel namespace. Subscriptions outside that namespace remain access-checked, with integration tests covering both outcomes. ChangesChannel subscription scope
Estimated code review effort: 2 (Simple) | ~15 minutes Sequence Diagram(s)sequenceDiagram
participant WebSocketClient
participant handleRequest
participant AccessCheck
participant RuntimeEvents
WebSocketClient->>handleRequest: session.subscribe(sessionId)
alt sessionId matches channel namespace
handleRequest->>RuntimeEvents: subscribeFrom(sessionId)
RuntimeEvents-->>WebSocketClient: subscribed=true
else sessionId is outside namespace
handleRequest->>AccessCheck: requireSessionAccess(sessionId)
AccessCheck-->>WebSocketClient: SESSION_NOT_FOUND
end
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@apps/gateway/test/ws-subscribe-scope.test.ts`:
- Around line 105-107: Update both finally blocks in
apps/gateway/test/ws-subscribe-scope.test.ts at lines 105-107 and 119-121 to
await the asynchronous server.close() operation by wrapping it in a promise.
Ensure each test waits for the listener to be fully released before finishing.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: ba6eba50-ac4f-4088-8918-14d352cba2bc
📒 Files selected for processing (2)
apps/gateway/src/ws-handler.tsapps/gateway/test/ws-subscribe-scope.test.ts
|
please review @williamwa. |
The web channel's out-of-band subscription client (amiko-chat, amiko-platform #1229) authenticates with a bare channel token, which carries no channelUserId, so since b24f5bc every session.subscribe was rejected with SESSION_NOT_FOUND and generated media never reached chat. This restores the namespace carve-out from #231 that was dropped when it got reworked into #238: channel-token connections may subscribe to sessions inside their own namespace, mirroring the SSE events route. User JWTs keep the participant check.
Covered by apps/gateway/test/ws-subscribe-scope.test.ts.
Summary by CodeRabbit
New Features
namespace:*).Bug Fixes
session.subscribeauthorization behavior to correctly apply access checks based on the connection’s auth scope, preventing unauthorized cross-namespace subscriptions.Tests
SESSION_NOT_FOUNDoutside it.