Skip to content

Commit 992b0a3

Browse files
committed
Merge branch '6.2' into 6.3
* 6.2: [LoginLink] Add technical details
2 parents 3470f4b + 63199ec commit 992b0a3

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

security/login_link.rst

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,13 @@ The signed URL contains 3 parameters:
404404
properties. Whenever these change, the hash changes and previous login
405405
links are invalidated.
406406

407+
For a user that returns ``user@example.com`` on ``$user->getUserIdentifier()``
408+
call, the generated login link looks like this:
409+
410+
.. code-block:: text
411+
412+
http://example.com/login_check?user=user@example.com&expires=1675707377&hash=f0Jbda56Y...A5sUCI~TQF701fwJ...7m2n4A~
413+
407414
You can add more properties to the ``hash`` by using the
408415
``signature_properties`` option:
409416

@@ -647,6 +654,23 @@ user create this POST request (e.g. by clicking a button)::
647654
</form>
648655
{% endblock %}
649656

657+
Hashing Strategy
658+
~~~~~~~~~~~~~~~~
659+
660+
Internally, the :class:`Symfony\\Component\\Security\\Http\\LoginLink\\LoginLinkHandler`
661+
implementation uses the
662+
:class:`Symfony\\Component\\Security\\Core\\Signature\\SignatureHasher` to create the
663+
hash contained in the login link.
664+
665+
This hasher creates a first hash with the expiration
666+
date of the link, the values of the configured signature properties and the
667+
user identifier. The used hashing algorithm is SHA-256.
668+
669+
Once this first hash is processed and encoded in Base64, a new one is created
670+
from the first hash value and the ``kernel.secret`` container parameter. This
671+
allows Symfony to sign this final hash, which is contained in the login URL.
672+
The final hash is also a Base64 encoded SHA-256 hash.
673+
650674
Customizing the Success Handler
651675
-------------------------------
652676

0 commit comments

Comments
 (0)