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
Copy file name to clipboardExpand all lines: security/login_link.rst
+22-2Lines changed: 22 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -111,9 +111,9 @@ intercept requests to this route:
111
111
throw new \LogicException('This code should never be reached');
112
112
}
113
113
}
114
-
114
+
115
115
.. code-block:: php-attributes
116
-
116
+
117
117
// src/Controller/SecurityController.php
118
118
namespace App\Controller;
119
119
@@ -428,6 +428,9 @@ The signed URL contains 3 parameters:
428
428
properties. Whenever these change, the hash changes and previous login
429
429
links are invalidated.
430
430
431
+
For a user that returns ``user@example.com`` on ``$user->getUserIdentifier()``
432
+
call, the generated login link looks like this: ``http://example.com/login_check?user=user@example.com&expires=1675707377&hash=f0Jbda56Y...A5sUCI~TQF701fwJ...7m2n4A~``
433
+
431
434
You can add more properties to the ``hash`` by using the
432
435
``signature_properties`` option:
433
436
@@ -673,6 +676,23 @@ user create this POST request (e.g. by clicking a button)::
673
676
</form>
674
677
{% endblock %}
675
678
679
+
Hashing strategy
680
+
~~~~~~~~~~~~~~~~
681
+
682
+
Internally, the :class:`Symfony\\Component\\Security\\Http\\LoginLink\\LoginLinkHandler`
683
+
implementation uses the
684
+
:class:`Symfony\\Component\\Security\\Core\\Signature\\SignatureHasher` to create the
685
+
hash contained in the login link.
686
+
687
+
This hasher creates a first hash with the expiration
688
+
date of the link, the values of the configured signature properties and the
689
+
user identifier. The used hashing algorithm is SHA-256.
690
+
691
+
Once this first hash is processed and encoded in base 64, a new one is created
692
+
from the first hash value and the ``kernel.secret`` container parameter. This
693
+
allows Symfony to sign this final hash, which is contained in the login URL.
694
+
This final hash is also a base 64 encoded SHA-256 hash.
0 commit comments