-
Notifications
You must be signed in to change notification settings - Fork 212
Open
Description
Hello guys.
I have reviewed this chapter and I noticed a problem.
In this section, the CSRF token is not checked and this is a serious problem.
src/AppBundle/Security/LoginFormAuthenticator.php
public function getCredentials(Request $request)
{
$isLoginSubmit = $request->getPathInfo() == '/login' && $request->isMethod('POST');
if (!$isLoginSubmit) {
// skip authentication
return;
}
$form = $this->formFactory->create(LoginForm::class);
$form->handleRequest($request);
$data = $form->getData();
return $data;
}
And I considered the following solution for it:
if ( $form->isSubmitted() && $form->isValid() )
{
$data = $form->getData();
return $data;
}
throw new CustomUserMessageAuthenticationException("The CSRF token is invalid!");
I hope that this issue will be useful.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels