Skip to content

fix(multitenancy): pin the live-query websocket stream to the tenant team - #114

Merged
oleksandrd-flamingo merged 1 commit into
mainfrom
feature/openframe-campaign-tenant-pin
Aug 18, 2026
Merged

fix(multitenancy): pin the live-query websocket stream to the tenant team#114
oleksandrd-flamingo merged 1 commit into
mainfrom
feature/openframe-campaign-tenant-pin

Conversation

@oleksandrd-flamingo

Copy link
Copy Markdown

The live-query results websocket (sockjs) rebuilds its context from
context.Background(), discarding the upgrade-request context that
WithOpenframeTenant pinned. In shared mode the whole campaign stream ran
unfenced, and live_query rows in activity_past got team_id = NULL, so the
CDC pipeline couldn't attribute them to a tenant. Since all tenants share the
same Fleet Admin user, the upstream campaign.UserID check doesn't isolate
tenants — a foreign campaign id could be streamed cross-tenant.

  • endpoint_campaigns.go: re-apply the team pin from session.Request()'s
    context; fail closed in shared mode if no pin is present
  • campaigns.go: fence DistributedQueryCampaign /
    DistributedQueryCampaignTargetIDs by the campaign's query team (EXISTS
    against queries.team_id) when pinned

Flag off / unpinned: statements and behavior are byte-identical to upstream.

Tests: websocket re-pin + unpinned pass-through (httptest sockjs handshake),
MySQL-backed cross-tenant fence test.

🤖 Generated with Claude Code

…team

The sockjs results handler rebuilt its context from Background, dropping the
tenant pin set on the upgrade request — the campaign stream ran unfenced and
live_query activities were stamped with a NULL team_id. Re-pin from the upgrade
request (fail closed in shared mode) and fence campaign-by-id reads via the
campaign's query team.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@oleksandrd-flamingo
oleksandrd-flamingo enabled auto-merge (squash) August 18, 2026 12:00
@oleksandrd-flamingo
oleksandrd-flamingo merged commit c06f399 into main Aug 18, 2026
5 checks passed
@oleksandrd-flamingo
oleksandrd-flamingo deleted the feature/openframe-campaign-tenant-pin branch August 18, 2026 12:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants