Skip to content

[Mercure] update mercure doc to add clarification in authorization #12779

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 9, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion mercure.rst
Original file line number Diff line number Diff line change
Expand Up @@ -364,10 +364,17 @@ a JWT containing a topic selector matching by the update's topic.

To provide this JWT, the subscriber can use a cookie,
or a ``Authorization`` HTTP header.
Cookies are automatically sent by the browsers when opening an ``EventSource`` connection.

Cookies are automatically sent by the browsers when opening an ``EventSource`` connection if the ``withCredentials`` attribute is set to ``true``.
Using cookies is the most secure and preferred way when the client is a web browser.
If the client is not a web browser, then using an authorization header is the way to go.

.. code-block:: javascript

const eventSource = new EventSource(hub, {
withCredentials: true
});

.. tip::

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