You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After discussions at EU FOSSA Hackathon we have some ideas on how to rework the Security component. I'm writing this "tracker issue" to gather up the info and choices made thus far.
The biggest functional issues have been discussed frequently over the years (#10316 and others) that the authentication makes some shortcut assumptions no longer valid in 2019:
The object of security considerations is not always a user, it may be a device, a computer, an API key, or any number of other abstract things. In the security world the concept of "something that can participate in security questions" is called a Principal.
There should be a functional separation between the Principal performing an action and the Context he is in while doing so. Authorization decisions should be based on the presented Context. This solves many practical issues like impersonation and "act as company".
Principals may be authenticated by various means, and be oblivious themselves on the subject. Principals should therefore not expose functionality to get passwords or roles as they may not have any. Tokens handle authentication.
The Symfony Security component was originally based on the Java Spring Security framework, but has deviated over the years. Today Spring Security has both fixed some structural issues that Symfony has (the notion of principals versus users and no central assumption that passwords and roles exist) and has some features that are currently lacking or hacky at best (structural support for OpenID/OAuth, support for 2FA). Conclusion for now is that most of the current Security component, especially authorization, is mostly fine and does not need a lot of work, and it wouldn't be all that hard to fix the authentication parts, and more strongly decouple authentication and authorization, by taking some current inspiration from Spring again.
Once these changes are propagated a lot of other features related to authentication should be easier to implement. Wishlists have been assembled:
Authentication
User impersonation (including multiple impersonation without having to log out) not affected by Security changes
Easy to add new authentication mechanisms (as Guard currently offers)
Easy customization of provided authentication mechanisms (especially form_login, which is the most complex and most used one): through events/hooks? Or implement those as Guards, we can easily decorate/override?
More events: at least having an event before a login is attempted, which could be used to implement custom rate-limiting mechanism
"Access control" to set permissions over web site sections using regexps not affected by Security changes
Native @Security annotation to set the permissions of controller classes and/or actions not affected by Security changes
Grant or deny permissions based on trust levels, such as whether 2FA is enabled or "sudo mode" is required
Having an opinionated way to set up object-level control mechanism (CRUD). Voters tend to be a little bit too general in my opinion, making necessary to set up per project conventions (ie, you have to check for “EDIT” attribute…), which can’t be enforced programmatically now.
Users
Dropping the notion of users at the lowest level must not mean DX suffers and developers need to write a lot of boilerplate again. In fact directly implementing PrincipalInterface should likely be considered an advanced subject, and we should provide a layer with abstract and stock implementation of common user-based scenarios:
Allow to represent application users with a User class (bonus: help you create it with make:user). not affected by Security changes
Allow to get a User object very easily from a Twig template. not affected by Security changes
“Remember Me” feature (access to the app without having to log in again; and allow to differentiate those users from both anonymous users and users who logged in for real) ([Security] Rework the remember me system #40145)
Roles (to have different kinds of users: normal users, admins, etc.) not affected by Security changes
Allow to hash user passwords (Bcrypt, Argon2i, etc. but not old algorithms with custom salts) (
Allow to log in users programmatically in an easy way (e.g. $security->login(‘username’))
Make it trivial to test protected resources (logging in a user in tests should be very easy)
Password validators (check if password is too simple, if it has been compromised before, etc.)
Have minimal requirements/assumptions about User class from Security component, so decoupling is easier (which is a pretty popular topic, actually). Only requiring username/password, likely? ([Security] Decouple passwords from UserInterface #40267)
Non-wishlist
As we are committed to using voters for authorization, and do not want to have/support 2 mechanisms serving similar or mostly identical purposes we will not implement ACLs again
After discussions at EU FOSSA Hackathon we have some ideas on how to rework the Security component. I'm writing this "tracker issue" to gather up the info and choices made thus far.
The biggest functional issues have been discussed frequently over the years (#10316 and others) that the authentication makes some shortcut assumptions no longer valid in 2019:
The Symfony Security component was originally based on the Java Spring Security framework, but has deviated over the years. Today Spring Security has both fixed some structural issues that Symfony has (the notion of principals versus users and no central assumption that passwords and roles exist) and has some features that are currently lacking or hacky at best (structural support for OpenID/OAuth, support for 2FA). Conclusion for now is that most of the current Security component, especially authorization, is mostly fine and does not need a lot of work, and it wouldn't be all that hard to fix the authentication parts, and more strongly decouple authentication and authorization, by taking some current inspiration from Spring again.
Once these changes are propagated a lot of other features related to authentication should be easier to implement. Wishlists have been assembled:
Authentication
Social login (login in the app using Google, Facebook, GitHub, Twitter, etc.) and generic OAuth support([WIP][Security] OAuth2 component #31952 (comment))Two-factor (or multi-factor) authentication([Security] Native support for 2FA #28868 (comment))Authorization
Users
Dropping the notion of users at the lowest level must not mean DX suffers and developers need to write a lot of boilerplate again. In fact directly implementing
PrincipalInterfaceshould likely be considered an advanced subject, and we should provide a layer with abstract and stock implementation of common user-based scenarios:Allow to easily differentiate anonymous users and logged in users.([Security] Removed anonymous in the new security system #36574 (comment))make::reset-password)$security->login(‘username’))Non-wishlist
/cc @wouterj @derrabus @linaori @sstok