feat: upgrade to Mercure 1.0 alpha 3 - #2611
Draft
dunglas wants to merge 1 commit into
Draft
Conversation
Publish-side validation is part of the protocol now: report what Update.Validate() rejects (reserved topics and event types, forbidden event IDs, invalid UTF-8 data) as a ValueError carrying the reason, and the dispatch failures as a RuntimeException. The subscribe query parameter becomes "match", so hot reloading advertises its topic with it. The publisher_jwt and subscriber_jwt directives now require the compatibility mode, which drops the audience, expiration and issuer checks: bind the keys to a trusted issuer instead.
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.
Upgrades
github.com/dunglas/mercureandgithub.com/dunglas/mercure/caddyfromv0.24.2tov1.0.0-alpha.3, and adapts the integration to the protocol changes of draft-dunglas-mercure-08.mercure_publish()The hub validates updates before dispatching them, so the function now distinguishes the caller's mistakes from a failed publication:
ValueErrorcarrying the reason for a topic addressing the reserved/.well-known/mercurenamespace or equal to*, an$idstarting with#or equal toearliest, a$typeequal tomercure, control characters, invalid UTF-8$data, or no topic at all;RuntimeExceptionwith the message of the hub when the dispatch fails.The negative values of
$retryare also rejected, as the protocol only allows digits in that field.An enum in
frankenphp.hreplaces the status codesgo_mercure_publish()returned as bare integers. On the way, an array of topics that cannot be converted no longer reportsNo Mercure hub configured.Hot reloading
The subscribe query parameter of the protocol is
match, so$_SERVER['FRANKENPHP_HOT_RELOAD']advertises/.well-known/mercure?match=<topic>. Thetopicparameter it replaces is only honored by a hub built with thedeprecated_topictag, which FrankenPHP doesn't set.Hub configuration
Setting
publisher_jwtorsubscriber_jwtwithoutprotocol_version_compatibilityis a configuration error now, because that mode also drops the requiredexp, the audience check, theat+jwtcheck and the issuer check. The keys are bound to a trusted issuer instead:php-server --mercureand the sampleCaddyfilefollow, and the access tokens using the 0.xmercureclaim are rejected: FrankenPHP is built without the compatibility tags of the hub.Notes
docs/mercure.mdstill describe the 0.x configuration.symfony/mercure0.8 forProtocolVersion::V1, unreleased as this hub is still an alpha.