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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correctly handle denied access in the firewall #6805

Merged
merged 18 commits into from Feb 1, 2024

Conversation

aschempp
Copy link
Member

@aschempp aschempp commented Jan 29, 2024

This now fixes and improves a lot of things 馃檲

  1. Fixes the authentication system to correctly render the Contao login page even if the current route is not a Contao page (e.g. a custom controller)
  2. Fixes the ContaoLoginAuthenticator from rendering the wrong page for login (if the user is not fully authenticated).
  3. Fixes the remember me authentication system (see Drop the custom "remember me" implementation聽#6815)
  4. Adds an AccessDeniedHandler to render the 403 page via the firewall exception handler
  5. Correctly enforces fully authentication for changing personal data, changing the user password and configuring two-factor authentication
  6. Removes the ExceptionConverter and PrettyErrorScreen from rendering 401 and 403 pages, because these are rendered by the firewall

There are two "behaviour changes" I can think of

  • obviously the fully-authentication works and is now enforces as described in point 4
  • If no 401 or 403 pages are configured in root page, we now render the generic error (through the pretty error screen listener) instead of the generic Symfony 401/403 message. Since we are in Contao frontend scope, I think that should be fine.

TODO:

  • Needs a migration for existing RememberMe tokens (the migration tool cannot migrate binary data to string value because the binary data is null-padded and therefore longer than the new string field).

@aschempp aschempp added the bug label Jan 29, 2024
@aschempp aschempp added this to the 5.3 milestone Jan 29, 2024
@aschempp aschempp marked this pull request as ready for review January 30, 2024 07:53
@aschempp aschempp requested review from bytehead and a team January 30, 2024 07:53
Toflar
Toflar previously approved these changes Jan 30, 2024
Copy link
Member

@Toflar Toflar left a comment

Choose a reason for hiding this comment

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

Sure needs some manual testing which I currently don't have the time for but from a logical standpoint, the code looks good to me.

Toflar
Toflar previously approved these changes Jan 30, 2024
Copy link
Member

@leofeyer leofeyer left a comment

Choose a reason for hiding this comment

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

The code works fine, however, on the 401 page, I can log in as a different user now. Shouldn鈥榯 we remove the username field in this case?

@aschempp
Copy link
Member Author

You are right. Username field removed in 9dc8d9e

I also manually tested the two-factor authentication, which was bumpy even for the regular login 馃檲

aschempp and others added 2 commits January 31, 2024 10:59
Co-authored-by: Leo Feyer <1192057+leofeyer@users.noreply.github.com>
@leofeyer leofeyer changed the title Correctly handle denied access in firewall Correctly handle denied access in the firewall Jan 31, 2024
@leofeyer leofeyer merged commit 719479a into contao:5.3 Feb 1, 2024
17 checks passed
@leofeyer
Copy link
Member

leofeyer commented Feb 1, 2024

Thank you @aschempp.

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.

None yet

3 participants