feat(router): add ReBAC-protected event-to-socket relays - #1600
Open
JohnChantz wants to merge 4 commits into
Open
JohnChantz wants to merge 4 commits into
JohnChantz wants to merge 4 commits into
Conversation
This was referenced Sep 11, 2026
Contributor
Author
kkopanidis
added this pull request to stack #1603
September 11, 2026 17:43
Forward exact Redis bus events as templated Socket.io messages on /events/, with resource-scoped rooms and local-only HA emission.
kkopanidis
force-pushed
the
feat/router-event-relays
branch
from
September 11, 2026 17:44
cd4dab0 to
6a3aa00
Compare
This was referenced Sep 12, 2026
…ger) (#1604) * fix(router): harden event relays for HA and auth lifetime EventBus uses a single Redis message dispatcher with subscriberId maps, SIGTERM/SIGINT shutdown, and subscribe-after-ACK. Hermes installs engine middleware once, skips empty-room namespace broadcasts, demotes hot-path logs, and re-authenticates recovered /events/ subscriptions. EventRelayManager gains coalesced periodic reconcile, compiled templates, inbound caps, TTL-cached emit-time ReBAC, room eviction, backpressure, preview API, and metrics/docs aligned with the interventions plan. * fix(router): address #1604 re-review P1 and P2 follow-ups Recovery re-auth keeps per-user subscription state across disconnect; emit-time ReBAC distinguishes unavailable vs deny; EventBus drops process signal handlers and adds subscribeAck; manager subscribes only after Redis ACK and broadcasts evictRelayIds on refresh; Hermes backpressure uses local sockets without emit acks; cache is bounded; preview caps sample JSON; handshake matcher rejects ticket/sid/non-namespace paths; socket middleware rebind avoids duplicate registration on first sockets enable. * fix(hermes): restore production tsc for engine middleware chain Type the Socket.IO engine middleware runner as Express NextFunction so recursive callbacks match registerGlobalMiddleware. Use Logger.info for socket trace lines (IConduitLogger has no debug). * fix(router): import Express Response for socket global middleware _rebindSocketGlobalMiddlewares passes handlers typed with fetch Response because Response was not imported from express, failing tsc against Hermes registerSocketGlobalMiddleware. * fix(router): quit EventBus on module shutdown signals Stop event relays and call grpcSdk.bus.quit() from Router.shutdown(), registered on SIGTERM/SIGINT with process exit so Redis teardown is not left to SDK signal handlers. Tighten registerGlobalMiddleware typing and trim handshake helper comment (deslop). * fix(router): pass-3 recovery, scoped emit, and subscription hygiene Recovery re-auth keeps membership on Authorization UNAVAILABLE and only leaves on deny; re-check subscriptions for restored er: rooms via room map. Prune user subscriptions on disconnect when no other socket holds them. Scope relay emits to receivers in the target room; use Engine.IO writeBuffer/writable for backpressure. Drop hot-path Hermes socket info logs. * fix(router): pass-4 recovery map, backpressure, emit tests Store relay subs on socket.data; resolve recovered rooms from context and TTL room map without last-writer userId. Prune room map when unused on disconnect. Backpressure uses writeBuffer depth only. Add Hermes/router tests for room-scoped emit and queue metric. * fix(router): clear eventRelaySubs from socket.data on recovery deny * fix(router): clear socket.data subs on recovery fail-closed leave
|
|
||
| getLocalRoomUserIds(namespace: string, room: string): Promise<string[]> { | ||
| return ( | ||
| this._socketRouter?.getLocalRoomUserIds(namespace, room) ?? Promise.resolve([]) |
|
|
||
| getLocalRoomsWithPrefix(namespace: string, prefix: string): Promise<string[]> { | ||
| return ( | ||
| this._socketRouter?.getLocalRoomsWithPrefix(namespace, prefix) ?? |
Split validateEventRelayInput into per-field parsers to reduce complexity. Silence unused-parameter lint in EventBus test FakeRedis stub.
This was referenced Sep 13, 2026
kkopanidis
added a commit
that referenced
this pull request
Sep 14, 2026
…sume-ab98 fix(database): merge-commit restack onto #1600 and drop Mongo resume
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.
What kind of change does this PR introduce?
Does this PR introduce a breaking change?
The PR fulfills these requirements:
mainbranchfix #xxx, where "xxx" is the issue number)If adding a new feature, the PR's description includes:
Other information:
Split from #1594 (1/3). Follow-ups: Mongo live updates, then SQL live updates.
Apps need to forward exact Redis bus events to Socket.io without REST polling. Relays stay authorization-aware: subscribe is allowed only when
User:<id>has the configured permission on<resourceType>:<resourceId>.Summary
Admin-configured, ephemeral mappings from an exact Redis bus channel to a templated Socket.io event on
/events/. Clients subscribe withrelayId+resourceId; rooms are derived server-side. Admin CRUD is at/router/event-relays. Emission is local-only so HA instances do not duplicate.Companion Admin UI: ConduitPlatform/Conduit-UI#327
Test plan
pnpm --filter @conduitplatform/router test): channel matching, template rendering, ReBAC authorize, subscribe/unsubscribe roomsPERMISSION_DENIED