-
-
Notifications
You must be signed in to change notification settings - Fork 341
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
[LiveComponent] Remove CSRF tokens - rely on same-origin/CORS instead #2251
Conversation
|
||
if (!$container->hasDefinition('test.client')) { | ||
$container->getDefinition('ux.live_component.event_subscriber') | ||
->setArgument(1, 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.
In test mode, we don't require the custom Accept
content-type to make testing easier (and not break existing tests).
799ae44
to
51bf1fb
Compare
Many developers, for various reasons(anwser stackoverflow), can add |
@onEXHovia thanks for the comment but I'm not sure what you're suggesting for this PR? |
If we consider this implementation and current with hidden token, I see two different scenarios. Without documentation developers may not know that live component depends on SOP in js for protections CSRF and added header Access-Control-Allow-Origin could mean potential CSRF. On the other hand, implementation with token is more explicit. Developer disable it through the component configuration and understands that could mean potential CSRF. Discussion in #2250
The same can be said about stateless requests, usually no one tries to make all requests stateless. I don't see any reason to remove the token based implementation, as a solution we could add a global configuration that configures the CSRF behavior for all components. |
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 is really nice! Ryan and I always wanted the possibility for stateless live components but csrf was our Achilles heel!
51bf1fb
to
6e94b02
Compare
I've just added a note about CSRF / CORS in the doc. |
LGTM :) @nicolas-grekas can you update the CHANGELOG in the src/LiveComponent repository ? |
6e94b02
to
e3c0ef5
Compare
CHANGELOG updated |
Thank you Nicolas. |
This PR replaces token-based CSRF-protection by same-origin/CORS policies.
It replaces #2250