Fix WebSocket JWT extraction dropping tokens due to unstrimmed whitespace - #613
Open
omaiko-intellecteu wants to merge 1 commit into
Open
Fix WebSocket JWT extraction dropping tokens due to unstrimmed whitespace#613omaiko-intellecteu wants to merge 1 commit into
omaiko-intellecteu wants to merge 1 commit into
Conversation
…pace
RFC 6455 clients send comma-space separated Sec-WebSocket-Protocol
values (e.g. "daml.ws.auth, jwt.token.<TOKEN>"), but the extraction
logic split on commas without trimming the resulting elements. The
leading space on the jwt.token.<TOKEN> segment caused the
startsWith("jwt.token.") check to fail, so the token was silently
dropped and the request proceeded unauthenticated (surfacing later as
GRPC UNAUTHENTICATED on the first response frame).
Extracts the parsing logic into extractWsJwtToken, trims each element
after splitting, and adds unit tests covering RFC 6455 formatting,
alternate spacing, and multi-token ordering.
Originally raised as canton-network/splice#6776.
|
✅ All required contributors have signed the CLA for this PR. Thank you! |
Author
|
I have hereby read the Digital Asset CLA and agree to its terms |
Author
|
recheck |
mziolekda
approved these changes
Aug 13, 2026
mziolekda
left a comment
There was a problem hiding this comment.
It look good. Thanks for the tests.
mziolekda
enabled auto-merge (squash)
August 13, 2026 11:23
soren-da
disabled auto-merge
August 19, 2026 06:57
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.
Fixes #614.
RFC 6455 clients send comma-space separated
Sec-WebSocket-Protocolvalues (e.g."daml.ws.auth, jwt.token.<TOKEN>"), but the JWT extraction logic inEndpoints.scalasplit on commas without trimming the resulting elements. The leading space on the token segment causedstartsWith("jwt.token.")to fail, so the token was silently dropped and the request proceeded unauthenticated — surfacing later as gRPCUNAUTHENTICATEDon the first response frame instead of failing at connection time.Extracts the parsing logic into
extractWsJwtToken, trims each element after splitting, and adds unit tests (EndpointsTest.scala) covering RFC 6455 formatting, alternate spacing, and multi-token ordering.Originally raised and fixed against the wrong repo in canton-network/splice#6776 / canton-network/splice#6777, so moving the fix upstream here.