Skip to content

Commit 7da7c6c

Browse files
committed
Merge branch '4.3' into 4.4
* 4.3: [#12605] Transformed GET parameter notice to caution access_control.rst: query string is ignored [mercure] compatibility with v0.8 Update doctrine.rst
2 parents 5f14232 + a818351 commit 7da7c6c

File tree

4 files changed

+18
-12
lines changed

4 files changed

+18
-12
lines changed

components/mercure.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Usage
2828
The following example shows the component in action::
2929

3030
// change these values accordingly to your hub installation
31-
define('HUB_URL', 'https://demo.mercure.rocks/hub');
31+
define('HUB_URL', 'https://demo.mercure.rocks/.well-known/mercure');
3232
define('JWT', 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJtZXJjdXJlIjp7InN1YnNjcmliZSI6WyJmb28iLCJiYXIiXSwicHVibGlzaCI6WyJmb28iXX19.LRLvirgONK13JgacQ_VbcjySbVhkSmHy3IznH3tA9PM');
3333

3434
use Symfony\Component\Mercure\Jwt\StaticJwtProvider;

doctrine.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -755,7 +755,7 @@ based on PHP conditions)::
755755
$qb = $this->createQueryBuilder('p')
756756
->where('p.price > :price')
757757
->setParameter('price', $price)
758-
->orderBy('p.price', 'ASC')
758+
->orderBy('p.price', 'ASC');
759759

760760
if (!$includeUnavailableProducts) {
761761
$qb->andWhere('p.available = TRUE')

mercure.rst

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ Run the following command to start it:
7171

7272
.. code-block:: terminal
7373
74-
$ JWT_KEY='aVerySecretKey' ADDR='localhost:3000' ALLOW_ANONYMOUS=1 CORS_ALLOWED_ORIGINS=* ./mercure
74+
$ ./mercure --jwt-key='aVerySecretKey' --addr='localhost:3000' --allow-anonymous --cors-allowed-origins='*'
7575
7676
.. note::
7777

@@ -94,7 +94,7 @@ The preferred way to configure the MercureBundle is using
9494
Set the URL of your hub as the value of the ``MERCURE_PUBLISH_URL`` env var.
9595
The ``.env`` file of your project has been updated by the Flex recipe to
9696
provide example values.
97-
Set it to the URL of the Mercure Hub (``http://localhost:3000/hub`` by default).
97+
Set it to the URL of the Mercure Hub (``http://localhost:3000/.well-known/mercure`` by default).
9898

9999
In addition, the Symfony application must bear a `JSON Web Token`_ (JWT)
100100
to the Mercure Hub to be authorized to publish updates.
@@ -189,7 +189,7 @@ Subscribing to updates in JavaScript is straightforward:
189189

190190
.. code-block:: javascript
191191
192-
const eventSource = new EventSource('http://localhost:3000/hub?topic=' + encodeURIComponent('http://example.com/books/1'));
192+
const eventSource = new EventSource('http://localhost:3000/.well-known/mercure?topic=' + encodeURIComponent('http://example.com/books/1'));
193193
eventSource.onmessage = event => {
194194
// Will be called every time an update is published by the server
195195
console.log(JSON.parse(event.data));
@@ -201,7 +201,7 @@ and to use URI Templates as patterns:
201201
.. code-block:: javascript
202202
203203
// URL is a built-in JavaScript class to manipulate URLs
204-
const url = new URL('http://localhost:3000/hub');
204+
const url = new URL('http://localhost:3000/.well-known/mercure');
205205
url.searchParams.append('topic', 'http://example.com/books/1');
206206
// Subscribe to updates of several Book resources
207207
url.searchParams.append('topic', 'http://example.com/books/2');
@@ -295,7 +295,7 @@ by using the ``AbstractController::addLink`` helper method::
295295
// This parameter is automatically created by the MercureBundle
296296
$hubUrl = $this->getParameter('mercure.default_hub');
297297

298-
// Link: <http://localhost:3000/hub>; rel="mercure"
298+
// Link: <http://localhost:3000/.well-known/mercure>; rel="mercure"
299299
$this->addLink($request, new Link('mercure', $hubUrl));
300300

301301
return $this->json([
@@ -311,7 +311,7 @@ and to subscribe to it:
311311
.. code-block:: javascript
312312
313313
// Fetch the original resource served by the Symfony web API
314-
fetch('/books/1') // Has Link: <http://localhost:3000/hub>; rel="mercure"
314+
fetch('/books/1') // Has Link: <http://localhost:3000/.well-known/mercure>; rel="mercure"
315315
.then(response => {
316316
// Extract the hub URL from the Link header
317317
const hubUrl = response.headers.get('Link').match(/<([^>]+)>;\s+rel=(?:mercure|"[^"]*mercure[^"]*")/)[1];
@@ -420,7 +420,7 @@ And here is the controller::
420420
$response = $this->json(['@id' => '/demo/books/1', 'availability' => 'https://schema.org/InStock']);
421421
$response->headers->set(
422422
'set-cookie',
423-
sprintf('mercureAuthorization=%s; path=/hub; secure; httponly; SameSite=strict', $token)
423+
sprintf('mercureAuthorization=%s; path=/.well-known/mercure; secure; httponly; SameSite=strict', $token)
424424
);
425425

426426
return $response;
@@ -460,7 +460,7 @@ Then, reference this service in the bundle configuration:
460460
mercure:
461461
hubs:
462462
default:
463-
url: https://mercure-hub.example.com/hub
463+
url: https://mercure-hub.example.com/.well-known/mercure
464464
jwt_provider: App\Mercure\MyJwtProvider
465465
466466
.. code-block:: xml
@@ -470,7 +470,7 @@ Then, reference this service in the bundle configuration:
470470
<config>
471471
<hub
472472
name="default"
473-
url="https://mercure-hub.example.com/hub"
473+
url="https://mercure-hub.example.com/.well-known/mercure"
474474
jwt-provider="App\Mercure\MyJwtProvider"
475475
/>
476476
</config>
@@ -483,7 +483,7 @@ Then, reference this service in the bundle configuration:
483483
$container->loadFromExtension('mercure', [
484484
'hubs' => [
485485
'default' => [
486-
'url' => 'https://mercure-hub.example.com/hub',
486+
'url' => 'https://mercure-hub.example.com/.well-known/mercure',
487487
'jwt_provider' => MyJwtProvider::class,
488488
],
489489
],

security/access_control.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,12 @@ if ``ip``, ``port``, ``host`` or ``method`` are not specified for an entry, that
144144
| | | | | | | URI doesn't match any of the ``path`` values. |
145145
+-----------------+-------------+-------------+-------------+------------+--------------------------------+-------------------------------------------------------------+
146146

147+
.. caution::
148+
149+
Matching the URI is done without ``$_GET`` parameters.
150+
:ref:`Deny access in PHP code <security-securing-controller>` if you want
151+
to disallow access based on ``$_GET`` parameter values.
152+
147153
.. _security-access-control-enforcement-options:
148154

149155
2. Access Enforcement

0 commit comments

Comments
 (0)