Repository navigation
feat(socket): admin socket settings page and runtime config for the socket server - #722
Merged
Merged
Conversation
…ls on /stats With SOCKETCLUSTER_AUTH_KEY set, the socket server polls the API's signed GET int/v1/socket/config (SOCKETCLUSTER_CONFIG_URL, default derived from the authorize URL; SOCKETCLUSTER_CONFIG_POLL_SECONDS, default 30, 0 disables) and applies enabled, mode, client publish and origins at runtime. The environment is the starting value and the last good remote config survives an unreachable API. The key is now passed to SocketCluster whenever present, so switching auth on needs no restart; entering enforce at runtime disconnects sockets once so their subscriptions are re-authorized. /stats gains config and aggregated denials (no tokens or ids). Helm exposes the two new env vars.
Rebuilds Admin > Configure > Socket on the new int/v1/settings/socket endpoints: socket server status (reachable, effective switch and mode with their sources, key configured, connections, last config sync, out-of-sync and sync-error notices), the aggregated denials table, and a settings form where each field can be left to the environment (null). Saving into enforce asks for confirmation first; key_missing gets its own message. The key stays environment-only and the page says how to rotate it. Fixes an XSS in the test console: event content (channel data and refusal reasons from the network) was rendered with html-safe and is now escaped.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## release/v0.7.70 #722 +/- ##
===================================================
Coverage 100.00% 100.00%
Complexity 38 38
===================================================
Files 196 196
Lines 4028 4092 +64
===================================================
+ Hits 4028 4092 +64
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
roncodes
added a commit
that referenced
this pull request
Oct 16, 2026
* chore(release): v0.7.70 * feat(socket): admin socket settings page and runtime config for the socket server (#722) * feat(socket): poll the API for runtime socket config and report denials on /stats With SOCKETCLUSTER_AUTH_KEY set, the socket server polls the API's signed GET int/v1/socket/config (SOCKETCLUSTER_CONFIG_URL, default derived from the authorize URL; SOCKETCLUSTER_CONFIG_POLL_SECONDS, default 30, 0 disables) and applies enabled, mode, client publish and origins at runtime. The environment is the starting value and the last good remote config survives an unreachable API. The key is now passed to SocketCluster whenever present, so switching auth on needs no restart; entering enforce at runtime disconnects sockets once so their subscriptions are re-authorized. /stats gains config and aggregated denials (no tokens or ids). Helm exposes the two new env vars. * feat(console): admin socket settings page Rebuilds Admin > Configure > Socket on the new int/v1/settings/socket endpoints: socket server status (reachable, effective switch and mode with their sources, key configured, connections, last config sync, out-of-sync and sync-error notices), the aggregated denials table, and a settings form where each field can be left to the environment (null). Saving into enforce asks for confirmation first; key_missing gets its own message. The key stays environment-only and the page says how to rotate it. Fixes an XSS in the test console: event content (channel data and refusal reasons from the network) was rendered with html-safe and is now escaped. * test(console): match prettier wrapping in the socket settings test * test(console): Toggle renders a disabled state as an empty data-disabled attribute * docs(release): v0.7.70 notes cover every PR in the release branch * ci: retrigger the checks that the Actions billing lock refused to start * release: v0.7.70 upgrades to the published components core-api 1.6.71, fleetops 0.6.73, storefront 0.4.26 and registry-bridge 0.1.11 in composer.json, package.json, the lock files, the pnpm release-age exclusions and the submodule pointers. RELEASE.md already names these versions. * release: v0.7.70 ships storefront 0.4.27 The storefront hotfix (fleetbase/storefront#159: customer notes reach QPay orders and lead the order panel; network orders open without reloading the list) replaces 0.4.26 in composer.json, package.json, the lock files, the pnpm release-age exclusion and the submodule pointer. RELEASE.md covers it.
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
Admins can now manage socket authentication from Admin → Configure → Socket, and the socket server applies the changes at runtime without a restart.
Socket server (
socket/)SOCKETCLUSTER_AUTH_KEYis set, the server polls the API's signedGET int/v1/socket/configeverySOCKETCLUSTER_CONFIG_POLL_SECONDS(default 30;0disables). Requests are signed with the authorize key and time out after 2 s.SOCKETCLUSTER_CONFIG_URLdefaults to the authorize URL with/authorizereplaced by/config. Without a key there is no polling and the server uses its environment only, as before.enabled,mode(includingallowClientPublish = mode !== 'enforce') andorigins. Anullmode or origins falls back to the socket server's own environment value. The environment is the starting config. When the API is unreachable, times out or answers with something malformed, the last good config stays in force./publishand/statsalso work while auth is off. That way the API can publish over HTTP as soon as its own switch flips, before the next poll.enforceat runtime disconnects every socket once (close code 4100). Clients reconnect after their usual reconnect delay, and subscriptions made under looser auth go through the authorizer again./statsadditions:config: {enabled, mode, origins, source: env|api, last_sync_at, last_sync_error};denials: the top 50{client, prefix, reason, count, last_at}. The prefix is the channel up to its first., orother. Rows are capped and never contain tokens, subjects, company ids or full channel names.socketcluster.configUrl/configPollSeconds. docker-compose needs nothing new, since the default derives from the authorize URL.Which SocketCluster 17 settings can change live:
allowClientPublish,originsand_allowAllOriginsare plainAGServerfields, read on every inbound#publishand every handshake, so setting them on the running server works. Origin changes only affect new handshakes; open connections are not re-checked.Console (
console/)null). Saving intoenforceasks for confirmation, andkey_missinggets its own message.html-safe. It is now escaped text.Why
Before this, switching socket auth on or changing its mode or origins meant editing env on the API and the socket server and restarting both. This lets an admin roll out
logand thenenforcefrom the console and see what would be denied first.Related
GET/POST int/v1/settings/socket, signedGET int/v1/socket/config) intorelease/v1.6.71Tests
socket/test/: unit tests for the config URL/interval, runtime config, poller (signing, failures, timeout, no overlap) and denials aggregation. Real-server integration tests cover:enforceblocks client publish;/statsdenials contain no tokens or ids.console/tests/integration/components/configure/socket-test.js: covers every branch of the page component and the XSS fix.