Repository navigation
Conversation
…annel resolvers
- POST storefront/v1/customers/socket-token mints a customer principal (store key +
Customer-Token); 404 while socket auth is disabled, 401 without a customer of the
storefront's company.
- Checkout initialization responses carry socket_token (checkout kind, scp limited to
checkout.{public_id}) when socket auth is enabled; absent otherwise.
- Register storefront and checkout channel resolvers with core-api's
SocketChannelRegistry.
- QPay capture publishes {checkout, status, order, error} on checkout.{public_id}
instead of the raw payment row; a publish failure no longer fails the callback.
- Require fleetbase/core-api ^1.6.69.
This was referenced Oct 6, 2026
feat(socket-auth): show channel authorization failures in the sockets viewer
fleetbase/dev-engine#51
Open
Open
Open
Open
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
Storefront's part of realtime socket authentication: it mints the two principals Storefront owns and authorizes the two channel prefixes it owns.
POST storefront/v1/customers/socket-token: authenticated like the other customer endpoints (storefront key plus theCustomer-Tokenheader). It mints acustomertoken:subandidscome from the customer contact (uuid, public_id),cid/cpidfrom the storefront's company,sidis the store or network uuid, andenvislivebecause storefront keys have no test mode. The response is{token, expires_in, expires_at}. It returns 404 while socket auth is disabled (SocketToken::enabled()is false). It returns 401 when there is no authenticated customer, or when the customer does not belong to the storefront key's company.GET storefront/v1/checkouts/before, which the SDK callscheckout.initialize): when socket auth is enabled, the cash, Stripe and QPay responses gainsocket_token. So does the Stripe payment-intent update, which also creates a new checkout.socket_tokenis{token, expires_in, expires_at}for acheckoutprincipal:subis the checkout uuid,scpis["checkout.<checkout public_id>"], pluscid/cpidand the store or network assid. A guest can therefore listen to its own checkout and nothing else. The field is absent while socket auth is disabled, so existing response shapes are unchanged.SocketChannelRegistryfrom the service provider:storefront.{id}:idis a store or network uuid, public_id or key. Users and API credentials are allowed when it belongs to their company. A customer is allowed only for the storefront named in its token'ssid, within its company. Every other kind is denied.checkout.{id}:idis a checkout uuid or public_id. Users and API credentials are allowed when it belongs to their company. A customer is allowed only for checkouts it owns. Every other kind is denied; acheckouttoken'sscpalready limits it to its own channel.checkout.{public_id}, but the payload is now{checkout, status, order, error}instead of the raw QPay payment row:statusis one ofpaid,completedorfailed.orderis serialized asGET checkouts/statusreturns it, and is null on failure.use-qpay-checkoutreads{ order, error }from this event and passesorderstraight to the Order screen, so it gets a usable order.respond=1) is unchanged.Why
The socket server will start authorizing subscriptions (see the realtime socket-auth design). Storefront clients need a way to get tokens, and the socket server needs resolvers for the prefixes Storefront owns.
Dependency
Requires
fleetbase/core-api^1.6.69, the release that carriesSocketToken,SocketPrincipalandSocketChannelRegistry;composer.jsonis raised accordingly. This PR's CI cannot pass until that core-api release is tagged. No version bump here; the release branch does that.Test plan
Verified by CI (
composer test:unitand the coverage baseline). New and updated tests cover:SocketToken::verifyfor store and network keyssocket_tokenabsent/present on an initialized checkout, with itsscp,sid(store, or network fallback) andcpidstorefront/checkoutresolvers: lookup by uuid, public_id and key; cross-company denial; customer narrowing bysidand ownership; other kinds denied; registration through the providercompleted,paid,failed), order serialization matching checkout status, and a failed publish not failing the callbackAPI / docs impact
POST storefront/v1/customers/socket-token, and a new optionalsocket_tokenresponse field on checkout initialization.fleetbase/postmanand the storefront API docs onfleetbase/fleetbase.ioneed entries (follow-up).checkout.{id}realtime event payload changed shape, as described above.Related PRs
Part of the authenticated realtime channels rollout (socket auth), one PR per repo:
fleetbase/core-api ^1.6.69)fleetbase/fleetbase-socketserver, compose/helm/installer, console socket test page