-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Security\Csrf] Split CsrfTokenGenerator into CsrfTokenManager and TokenGenerator #9216
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
Conversation
if ($csrfTokenManager instanceof CsrfProviderInterface) { | ||
$csrfTokenManager = new CsrfProviderAdapter($csrfTokenManager); | ||
} elseif (null !== $csrfTokenManager && !$csrfTokenManager instanceof CsrfTokenManagerInterface) { | ||
throw new UnexpectedTypeException($csrfTokenManager, 'CsrfProviderInterface or CsrfTokenManagerInterface'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you should use FQCN in the message IMO
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought about that, but then it becomes insanely long
Thanks once again @stof for your invaluable feedback. I addressed your comments in the latest commit. |
…ger and TokenGenerator (bschussek) This PR was merged into the master branch. Discussion ---------- [Security\Csrf] Split CsrfTokenGenerator into CsrfTokenManager and TokenGenerator | Q | A | ------------- | --- | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #9210 | License | MIT | Doc PR | - This is a follow-up PR of #6554 that splits the CsrfTokenGenerator into two separate classes for generating and managing CSRF tokens. As a consequence, it is now possible to explicitly remove or refresh CSRF tokens if they should be used only once. See #9210 for more information. Commits ------- d4bb5f4 [Security\Csrf] Split CsrfTokenGenerator into CsrfTokenManager and TokenGenerator
* | ||
* @param string $tokenId The token ID | ||
* | ||
* @return Boolean Returns true if a token existed for this ID, false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this does not correspond with the implementation. the implementation calls storage->remove which does not return a boolean but string|null. so either the implementation is wrong or this phpdoc is wrong.
This PR was squashed before being merged into the master branch (closes #9311). Discussion ---------- [Csrf] component fixes | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #9216 | License | MIT | Doc PR | - - [Csrf] fixed some phpdocs - [Csrf] fixed return types (also #9216 (comment) ) - [Csrf] fixed test class namespaces Commits ------- d7eb8ff [Csrf] component fixes
…precation (jakzal) This PR was merged into the 2.7 branch. Discussion ---------- [FrameworkBundle] Document form.csrf_provider service deprecation | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #14899 | License | MIT | Doc PR | - `form.csrf_provider` was deprecated in #9216. Commits ------- 0fea66f [FrameworkBundle] Document form.csrf_provider service deprecation
…enerator` to `firewalls.logout.csrf_token_manager` (MatTheCat) This PR was merged into the 6.3 branch. Discussion ---------- [SecurityBundle] Rename `firewalls.logout.csrf_token_generator` to `firewalls.logout.csrf_token_manager` | Q | A | ------------- | --- | Branch? | 6.3 | Bug fix? | no | New feature? | no | Deprecations? | yes | Tickets | N/A | License | MIT | Doc PR | symfony/symfony-docs#17482 A long time ago, #6554 replaced `CsrfProviderInterface` by `CsrfTokenGeneratorInterface`, and #9216 split the latter into `CsrfTokenManagerInterface` and `TokenGeneratorInterface`. #9587 later introduced `csrf_token_generator`, which was already wrong at the time. Given that token generators exist, it feels weird to have to set <code>csrf_token_**generator**</code> to <code>security.csrf.token_**manager**</code> as mentioned in [the documentation](https://symfony.com/doc/current/reference/configuration/security.html#csrf-token-generator). As this confusion recently led to #48339, I propose to rename `firewalls.logout.csrf_token_generator` to `firewalls.logout.csrf_token_manager`. Commits ------- 0a0a98a [SecurityBundle] Rename `firewalls.logout.csrf_token_generator` to `firewalls.logout.csrf_token_manager`
This is a follow-up PR of #6554 that splits the CsrfTokenGenerator into two separate classes for generating and managing CSRF tokens. As a consequence, it is now possible to explicitly remove or refresh CSRF tokens if they should be used only once. See #9210 for more information.