I think it's interesting to see if and how we can reduce the magic (i.e. remove it or make it more obvious by providing helper classes/methods?)
As a developer you wouldn't expect to have to deal with expressions. It's easy to get a disconnect between the actual controllers, their routing paths, and the regular expressions in the firewall. It's also very easy to break things: when you change a routing path, you can accidentally move a controller outside the firewall, making it unprotected or broken because it relies on a logged in user to be available. Instead, you'd expect to be able to mark controllers, not request URI patterns to be behind a firewall. That way, if you change the routing path, the controller still remains behind the controller.
The template gets access to the authentication exception itself and the docs say, don't show getMessage(), use getMessageKey(). It would be better to pass some other type of object to the template/controller; one that only has the getMessageKey() method.
Other aspects you wouldn't expect are a login controller that only shows the login form (login happens in a kernel event subscriber), and a logout controller that doesn't do anything.
Example
No response
The text was updated successfully, but these errors were encountered:
I think for the firewall, defining an application wide regex also has a major advantage of making sure certain sections are secured (e.g. by relying only on controller based config, you need to remember to add it to new controllers). Maybe we can use attributes more as a "sanity check": e.g. check whether all #[Secured] controllers are within a firewall during compilation?
technically, you don't need a logout controller at all. you need a logout route (so that the router does not return a 404 when reaching that URL). The logout controller associated to that route is never executed as the firewall generates a response early when handling the logout. The only benefit of that logout controller is that it allows you to keep using annotations or attributes to define the route (by design, those formats cannot define a route without an associated controller)
Description
Source: https://twitter.com/matthiasnoback/status/1503652556186206211 by @matthiasnoback
I think it's interesting to see if and how we can reduce the magic (i.e. remove it or make it more obvious by providing helper classes/methods?)
Example
No response
The text was updated successfully, but these errors were encountered: