Skip to content

fix(mercure): support Mercure 1.0 - #709

Open
dunglas wants to merge 2 commits into
api-platform:mainfrom
dunglas:fix/mercure-1.0
Open

dunglas wants to merge 2 commits into
api-platform:mainfrom
dunglas:fix/mercure-1.0

Conversation

@dunglas

@dunglas dunglas commented Nov 26, 2026

Copy link
Copy Markdown
Member

Mercure 1.0 replaces the topic query parameter with match, and hubs reject the old parameter with a 400. Admin now subscribes with match by default. Set protocolVersion: '0.x' for older hubs.

This also removes the authorization cookie Admin wrote from JavaScript:

  • a cookie set from JavaScript can't be HttpOnly, so any XSS can read the JWT;
  • document.cookie can't set a cookie for another host, so it never reached a hub on another domain;
  • Path received the absolute hub URL, which browsers reject, so the cookie only reached the hub when Admin was served from /.

The server must now set the cookie (for instance with MercureBundle's mercure() Twig function or Authorization::setCookie()). The new withCredentials option sends it to the hub.

BC break: the jwt Mercure option is removed in favor of withCredentials.

A cookie written from JavaScript can't be HttpOnly, can't reach a hub on another host, and its Path got the absolute hub URL, which browsers reject. Let the server set the cookie and expose withCredentials to send it.
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.

1 participant