Skip to content
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

Force auto-generated CSRF token id #6724

Merged
merged 1 commit into from
Jan 15, 2025

Conversation

nicolas-grekas
Copy link
Contributor

@nicolas-grekas nicolas-grekas commented Jan 15, 2025

EA is currently sensitive to the form.csrf_token_id config option. When using the new recipe for CSRF shipped with 7.2, this config option is set to "submit", which leads to using the stateless CSRF protection. But because EA doesn't load the JS snippet that goes with this protection, the admin area is broken for such apps: CSRF validation fails.

This change decouples EA from the config option and forces Symfony to auto-generate the CSRF token id, which leads to using the statefull CSRF protection. Using the session in the admin area is normal, so that's totally fine.

An alternative would be to load the app's importmap in EA pages.
This could be nice as it would make easier to add custom JS to admin pages, but it would be a bit more involving, and a bit unrelated.

@javiereguiluz javiereguiluz modified the milestones: 5.x, 3.x, 4.x Jan 15, 2025
@javiereguiluz
Copy link
Collaborator

Nicolas, thanks a lot for the fix and the detailed explanation 🙏 I'm a bit lost with the recent CSRF changes, so your help here is much appreciated 🙇

@javiereguiluz javiereguiluz merged commit f4edbf0 into EasyCorp:4.x Jan 15, 2025
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants