Skip to content

Fix the default FrankenPHP Mercure JWT audience - #1

Merged
dunglas merged 2 commits into
dunglas:feat/mercure-broadcasterfrom
J3m5:fix/mercure-jwt-audience
Sep 7, 2026
Merged

Fix the default FrankenPHP Mercure JWT audience#1
dunglas merged 2 commits into
dunglas:feat/mercure-broadcasterfrom
J3m5:fix/mercure-jwt-audience

Conversation

@J3m5

@J3m5 J3m5 commented Sep 7, 2026

Copy link
Copy Markdown

This fixes the default JWT audience generated for FrankenPHP's built-in Mercure hub.

When neither url nor public_url is configured, the hub is exposed at the root-relative /.well-known/mercure endpoint. The subscriber JWT currently uses that relative URL as its aud claim.

Mercure protocol 1.0 validates the token audience against the hub resource identifier, which is absolute. For an application served from https://app.test, the expected audience is therefore:

https://app.test/.well-known/mercure

This change derives the default audience from the origin of app.url while keeping the hub's public URL itself root-relative.

Explicit claims.aud and public_url values continue to take precedence.

The regression coverage includes:

  • application URLs with paths, query strings, and fragments;
  • trailing slashes;
  • non-default ports;
  • IPv6 hosts;
  • HTTP localhost URLs;
  • explicit public URLs;
  • explicit single and multiple audiences;
  • a custom issuer.

Validation:

  • regression tests fail before the fix as expected;
  • 92 tests / 172 assertions pass after the fix;
  • targeted Pint and PHPStan checks pass.

This is intended to be merged into the Mercure broadcaster branch used by laravel#61474.

@J3m5
J3m5 marked this pull request as ready for review September 7, 2026 16:19
@dunglas
dunglas merged commit 68f2fc0 into dunglas:feat/mercure-broadcaster Sep 7, 2026
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.

2 participants