Skip to content

Return null when csrfToken is not valid #8062

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

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion security/guard_authentication.rst
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ and add the following logic::
$csrfToken = $request->request->get('_csrf_token');

if (false === $this->csrfTokenManager->isTokenValid(new CsrfToken('authenticate', $csrfToken))) {
throw new InvalidCsrfTokenException('Invalid CSRF token.');
return null;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @rubenrubiob, as said in #7996, such change is wrong as it would allow another guard to try to authenticate this request. To stop the process here an exception needs to be thrown.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, @HeahDude ,

Okay, I see it now. Nevertheless, if you throw an exception the application stays in a redirect loop until the browser kills it. Anyway, I will look further onto it in September, to try to solve the problem directly.

Thank you!

Regards.

}

// ... all your normal logic
Expand Down