Skip to content

Fix WebSocket JWT extraction dropping tokens due to unstrimmed whitespace - #613

Open
omaiko-intellecteu wants to merge 1 commit into
digital-asset:mainfrom
omaiko-intellecteu:fix/ws-jwt-trim-6776
Open

Fix WebSocket JWT extraction dropping tokens due to unstrimmed whitespace#613
omaiko-intellecteu wants to merge 1 commit into
digital-asset:mainfrom
omaiko-intellecteu:fix/ws-jwt-trim-6776

Conversation

@omaiko-intellecteu

@omaiko-intellecteu omaiko-intellecteu commented Aug 13, 2026

Copy link
Copy Markdown

Fixes #614.

RFC 6455 clients send comma-space separated Sec-WebSocket-Protocol values (e.g. "daml.ws.auth, jwt.token.<TOKEN>"), but the JWT extraction logic in Endpoints.scala split on commas without trimming the resulting elements. The leading space on the token segment caused startsWith("jwt.token.") to fail, so the token was silently dropped and the request proceeded unauthenticated — surfacing later as gRPC UNAUTHENTICATED on 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.

…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.
@github-actions

github-actions Bot commented Aug 13, 2026

Copy link
Copy Markdown

✅ All required contributors have signed the CLA for this PR. Thank you!
Posted by the CLA Assistant Lite bot.

@omaiko-intellecteu

Copy link
Copy Markdown
Author

I have hereby read the Digital Asset CLA and agree to its terms

@omaiko-intellecteu

Copy link
Copy Markdown
Author

recheck

@mziolekda mziolekda left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It look good. Thanks for the tests.

@mziolekda
mziolekda enabled auto-merge (squash) August 13, 2026 11:23
@soren-da
soren-da disabled auto-merge August 19, 2026 06:57
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.

WebSocket JWT authentication silently fails due to unstrimmed comma-separated subprotocol values

2 participants