Repository navigation
fix(lib-pairing): normalise the paired endpoint in the key, target and deny check - #177
Conversation
…d deny check The pairing store key and the channel routing target used the endpoint exactly as the client declared it, so spellings of one address differing only in case, default port or trailing slash were paired, and answered, separately. A Platform paired under such a spelling got its own pairing next to the real one. denyHosts matched case-sensitively, so a change of case slipped past it. Add PairingEndpoint.normalise and use it in PairingServiceImpl.makeKey, PairingChannel.clientTarget and PairingWebSocket.isDenyHost. Endpoints already in canonical form keep their key. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
munishchouhan
left a comment
There was a problem hiding this comment.
The approach is right, and I verified the part that matters: getPairingRecord goes through makeKey, so normalising there makes the lookup spelling-tolerant — which is exactly what lets Wave's tenant key normalise safely in seqeralabs/wave#1319. Keeping PairingRecord.endpoint as the client declared it is the right call too.
Requesting changes for three small things, two of which have a traced path to a worse state than before the PR. None is architectural; I'd approve with them in.
Worth knowing the stakes: wave#1319 is blocked on this publishing as lib-pairing:1.3.0, and it hashes normalise into Wave's private build ids, which are persisted and handed to clients. A silent fallback costs a re-pair here; over there it costs a changed id.
CI being green is consistent with all three — none of them has a test.
…s, empty endpoint - Lowercase scheme and host with Locale.ROOT, so a Turkish default locale no longer breaks the URI rebuild and falls back to the raw spelling - Lowercase denyHosts entries too, so a mis-cased entry still blocks - Route an empty endpoint to the 'service:' target instead of an NPE - Document that the output of PairingEndpoint.normalise is frozen Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
#177 bumped VERSION to 1.3.0 but its merge commit carried no [release] marker, so the Release step of Libseqera CI was skipped and 1.3.0 was never published. This commit carries the marker; publish.sh is idempotent and gated by the VERSION file, so it publishes 1.3.0 and nothing else. Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
Problem
A service pairs by opening the pairing socket and declaring its own address in the
endpointquery parameter. That string went verbatim into:PairingServiceImpl.makeKey)PairingChannel.clientTarget, which stripped only the scheme)PairingWebSocket.isDenyHost, a case-sensitivecontains)So
https://platform.acme.com/api,https://PLATFORM.acme.com/apiandhttps://platform.acme.com:443/api/were three separate pairings, each answered by whoever registered it. In Wave, where the tenant of a private record is meant to be the canonical endpoint (wave ADR20261029-workspace-ownership§2.3), a separate pairing for another spelling of an already-paired Platform lets its owner share that Platform's tenant while answering its own membership checks.denyHostscould also be bypassed with a change of case (FOO.NGROK.APP).Change
PairingEndpoint.normalise: lowercases the scheme and host, drops the default port and any trailing slash, keeps the path's case. This is the same rule as Wave'snormalisePlatformEndpoint.makeKey,clientTargetandisDenyHost, so every spelling of one address resolves to one pairing record and one set of clients, and the deny list matches the canonical form.PairingRecord.endpointkeeps the spelling the client declared.Upgrade
Endpoints already in canonical form, which is most of them, hash to the same key as before, so their records are found. A record paired under a non-canonical spelling is no longer found under the new key. The next heartbeat sees it missing and closes the session, and the client reconnects and pairs again. The pairing id and key pair change for those clients only.
Bumps lib-pairing to 1.3.0. Not tagged
[release]; add it when merging if this should publish.Not addressed
A second registration under an endpoint that's already paired joins the existing record and is added as another client of the same target. That was already true for the exact spelling. This change extends it to the variant spellings instead of giving them a pairing of their own. Authenticating who may pair an endpoint is a separate fix.
Testing
Compiles (
:lib-pairing:compileTestGroovy); tests not run locally. NewPairingEndpointTestcovers normalisation, key stability for canonical endpoints, one key and one target per address, and a case-insensitive deny-host test inPairingWebSocketTest.🤖 Generated with Claude Code