You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 776206a
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: CHANGELOG.md
+3Lines changed: 3 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,6 +7,9 @@ Every change that reaches `main` adds a line under **Unreleased**. When a versio
7
7
### Added
8
8
-`GET /_/layouts/{reference}` finds a layout by its `reference` as well as its UUID, the reference winning when both match, as for component groups; the response's `@id` stays the UUID IRI ([#615](https://github.com/components-web-app/api-components-bundle/pull/615))
9
9
10
+
### Fixed
11
+
- A request on a host that shares no registrable domain with the Mercure hub's public URL (a production alias, a tunnel) no longer 500s on login, JWT refresh, logout or a failed `/me`: no Mercure cookie is sent, a warning is logged, and only real-time is unavailable there ([#616](https://github.com/components-web-app/api-components-bundle/pull/616))
Copy file name to clipboardExpand all lines: CLAUDE.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -255,6 +255,7 @@ Resources are fetched and cached **individually**. Never embed related data outs
255
255
- The cookie is `__Secure-mercure_access_token`. symfony/mercure throws when building it for a plain-HTTP `public_url`; a plain-HTTP setup sets a prefix-less `cookie_name` on the hub.
256
256
-**The subscriber cookie and its token share the refresh token's lifetime** (#498): `MercureAuthorization` passes `exp` = now + `refresh_token.ttl` as an additional claim, which symfony/mercure (0.8 and 0.9) uses for both the token and the cookie, so the browser drops the cookie exactly when the hub would refuse it. `mercure.default_cookie_lifetime` does not apply to it. Pass `exp` as a `DateTimeImmutable`: an int is read as a relative lifetime for the cookie and is not accepted by lcobucci for the token. Re-issued on login and every JWT refresh, so a session slides; a clear (`getClearAuthorizationCookie()`) expires it.
257
257
-**A clear expires the subscriber cookie, never re-issues it.**`MercureAuthorization::getClearAuthorizationCookie()` (logout, an invalid or expired JWT, a failed `/me`) is symfony/mercure's `createClearCookie()` with the bundle's SameSite, so it has the login cookie's name, path, domain and secure flag and reads nothing from the security context: `LogoutEvent` is dispatched before the firewall clears the token, so a cookie built from grants there carries the signed-out user's grants. Afterwards the browser holds no grants, like a visitor who never signed in. **A failed `/me` expires the Mercure cookie whenever the request carries it, with or without the JWT cookie**: the JWT cookie expires with the session, the Mercure cookie does not, so an expired session sends only the Mercure cookie. A failed `/me` carrying neither sets no cookie.
258
+
-**A host outside the hub's domain gets no subscriber cookie, logged at warning, never a 500.** symfony/mercure refuses a cookie (set or clear) when the request host and the hub's `public_url` share no registrable domain (a production alias, a tunnel), throwing its `RuntimeException`. `MercureAuthorization::getAuthorizationCookie()`/`getClearAuthorizationCookie()` return `null` then, and every caller (login, refresh, logout, the JWT clear listeners) skips it, so the request carries on without real-time. The catch is that class only, rethrown unless `Utility\MercureCookieDomain::isOutside()`, which mirrors symfony/mercure's domain rule (`MercureCookieDomainTest` checks each case against the library), confirms the host is foreign: the token factory can throw the same class for a JWKS fetch. An `InvalidArgumentException` (JWT configuration, a `__Secure-` name over plain HTTP) always propagates.
258
259
-**The public update is what an anonymous `GET` returns** (#494). `MercureResourcePublisher` gets it from `AnonymousResourceReader`: an internal `SUB_REQUEST` (`catch: false`) for the resource's IRI with the writer's cookies, `Authorization`, body and conditional headers stripped, and the token storage set to `null` for its duration and restored in a `finally`. The firewall never runs on a sub-request, so clearing the token is the only way to be anonymous there; never swap the token inside the writer's request itself. A 401/403/404 (or a security exception) means anonymous callers cannot read it. Anything else propagates.
259
260
-**A public delete `{"@id"}` goes out only when the write itself took the resource from public to not public**, because a delete reveals the IRI (a route's IRI is its path). `MercureResourcePublisher::leftPublicInThisWrite()` decides it from the written entity's UoW change set, captured at `onFlush` (the change set is gone by `postFlush`, so a re-add keeps the first answer): a publication date or a Route's `liveAt` moving from active to inactive (future or null), a page's or page data's `route` unset, or its `parentPage`/`parentPageData` changed (then only if the anonymous read is denied). An unreadable resource with none of these gets nothing on the public topic; the private update still goes out. Never decide it with a before-state read. Descendants a write hides without being written get no message: a known limitation.
260
261
-**Services that memoise caller-dependent answers on shared objects implement `Utility\CallerScopedStateInterface`** and are tagged `silverback.api_components.caller_scoped_state` (`RouteReachabilityResolver`, `ResourceMetadataProvider`): the reader isolates them for the sub-request and restores them after, because entities are shared with the writer through the identity map. A new memo keyed by an entity or `_metadata` whose answer depends on the token must join the tag. `RouteLiveResolver` memoises only dates, which are caller-independent.
if (null === $host || !MercureCookieDomain::isOutside($host, $hubUrl)) {
85
+
throw$exception;
86
+
}
87
+
$this->logger?->warning('No Mercure subscriber cookie can be set for the host "{host}": it is outside the domain of the hub\'s public URL "{hub_url}", so real-time updates are unavailable on it.', [
0 commit comments