#93 Protect the login form against CSRF - #94
Open
njoubert-cleverage wants to merge 1 commit into
Open
njoubert-cleverage wants to merge 1 commit into
njoubert-cleverage wants to merge 1 commit into
Conversation
The prepended form_login configuration enables enable_csrf (token id `authenticate`, parameter `_csrf_token`) and LoginController passes csrf_token_intention, so that the EasyAdmin login template renders the token field. symfony/security-csrf is declared (it was only a transitive dependency). BC break for overridden login templates, see UPGRADE.md v4.0. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
Fixes #93.
Milestone v4.0 (BC break, see below).
CleverAgeUiProcessExtension::prepend():enable_csrf: trueon theform_loginof themainfirewall (token idauthenticate, parameter_csrf_token: theform_logindefaults, also used by the EasyAdmin login template)LoginController: passescsrf_token_intention: authenticate, so the EasyAdmin login template renders the_csrf_tokenhidden fieldcomposer.json:symfony/security-csrfdeclared (it was only installed as a transitive dependency)03-users_and_security.md(prepended configuration, CSRF requirements) andUPGRADE.mdv4.0 (overridden login template, opt-out); CHANGELOG entry underBC breakTests:
SecurityTest::testLoginWithAnInvalidCsrfToken: the login page has the_csrf_tokenfield; valid credentials with an invalid token are rejected (Invalid CSRF token.), the user stays logged out.testLoginstill logs in with the token of the pageCleverAgeUiProcessExtensionTest::testPrepend:enable_csrfin the prepended firewallChecked:
composer validate, PHPStan, PHP-CS-Fixer, Rector OKInvalid CSRF token., login with the token of the page redirects to the UILogout CSRF (
logout.enable_csrf) is not changed: the logout is a GET link of the EasyAdmin menu.Requirements
Breaking changes
Applications that override the login template without the
_csrf_tokenfield, or that submit the login form without it, must add it, or setenable_csrf: falseon theirmainfirewall (seeUPGRADE.md). The Symfony CSRF protection must be enabled (framework.csrf_protection, enabled by default when the session is).🤖 Generated with Claude Code