-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
[Security] [LoginLink] Add technical details #17872
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
javiereguiluz
merged 1 commit into
symfony:5.4
from
alexandre-daubois:login-link-details
Feb 8, 2023
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -111,9 +111,9 @@ intercept requests to this route: | |
throw new \LogicException('This code should never be reached'); | ||
} | ||
} | ||
|
||
.. code-block:: php-attributes | ||
|
||
// src/Controller/SecurityController.php | ||
namespace App\Controller; | ||
|
||
|
@@ -428,6 +428,13 @@ The signed URL contains 3 parameters: | |
properties. Whenever these change, the hash changes and previous login | ||
links are invalidated. | ||
|
||
For a user that returns ``[email protected]`` on ``$user->getUserIdentifier()`` | ||
call, the generated login link looks like this: | ||
|
||
.. code-block:: text | ||
|
||
http://example.com/[email protected]&expires=1675707377&hash=f0Jbda56Y...A5sUCI~TQF701fwJ...7m2n4A~ | ||
|
||
You can add more properties to the ``hash`` by using the | ||
``signature_properties`` option: | ||
|
||
|
@@ -673,6 +680,23 @@ user create this POST request (e.g. by clicking a button):: | |
</form> | ||
{% endblock %} | ||
|
||
Hashing Strategy | ||
~~~~~~~~~~~~~~~~ | ||
|
||
Internally, the :class:`Symfony\\Component\\Security\\Http\\LoginLink\\LoginLinkHandler` | ||
implementation uses the | ||
:class:`Symfony\\Component\\Security\\Core\\Signature\\SignatureHasher` to create the | ||
hash contained in the login link. | ||
|
||
This hasher creates a first hash with the expiration | ||
date of the link, the values of the configured signature properties and the | ||
user identifier. The used hashing algorithm is SHA-256. | ||
|
||
Once this first hash is processed and encoded in Base64, a new one is created | ||
from the first hash value and the ``kernel.secret`` container parameter. This | ||
allows Symfony to sign this final hash, which is contained in the login URL. | ||
The final hash is also a Base64 encoded SHA-256 hash. | ||
|
||
Customizing the Success Handler | ||
------------------------------- | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.