8000 minor #12779 [Mercure] update mercure doc to add clarification in aut… · githubfromgui/symfony-docs@53239ed · GitHub
[go: up one dir, main page]

Skip to content

Commit 53239ed

Browse files
committed
minor symfony#12779 [Mercure] update mercure doc to add clarification in authorization (chloebrqt)
This PR was submitted for the 4.3 branch but it was squashed and merged into the 4.4 branch instead. Discussion ---------- [Mercure] update mercure doc to add clarification in authorization Hello everyone, I've added a few words and a code example to clarify the doc about authorization in the Mercure Bundle, to indicate that the `withCredentials` attribute of the `EventSource` must be set to `true` for the authorization cookie to be sent to the Hub. I was missing this info when I installed Mercure for the first time (super protocol, by the way!) and learned about it while reading comments in response to an issue. By the way, this pull request should fix the closed issue dunglas/mercure#65. Thanks in advance and have a nice day! (This is my first pull request ever to an open-source project, all the more so to the Symfony repository, so I hope I did everything right.) Commits ------- e6080ae [Mercure] update mercure doc to add clarification in authorization
2 parents c0faf43 + e6080ae commit 53239ed

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

mercure.rst

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,10 +364,17 @@ a JWT containing a topic selector matching by the update's topic.
364364

365365
To provide this JWT, the subscriber can use a cookie,
366366
or a ``Authorization`` HTTP header.
367-
Cookies are automatically sent by the browsers when opening an ``EventS 8415 ource`` connection.
367+
368+
Cookies are automatically sent by the browsers when opening an ``EventSource`` connection if the ``withCredentials`` attribute is set to ``true``.
368369
Using cookies is the most secure and preferred way when the client is a web browser.
369370
If the client is not a web browser, then using an authorization header is the way to go.
370371

372+
.. code-block:: javascript
373+
374+
const eventSource = new EventSource(hub, {
375+
withCredentials: true
376+
});
377+
371378
.. tip::
372379

373380
The native implementation of EventSource doesn't allow specifying headers.

0 commit comments

Comments
 (0)
0