-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[RFC][Security] Simplify the User and UserChecker #26348
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
Comments
i am okay with that if the AdvancedUserInterface is removed. what more changes need to be done for stuff like FOSUser or SonataUser? |
Iltar, what would be the impact for the most common use case? Simple app with no fancy needs that only wants a |
The most common use-case would probably be an entity with the |
@javiereguiluz simple apps with no fancy needs don't need a user checker at all (just like they don't need to use the AdvancedUserInterface features today, and the built-in user checker is a no-op for non-advanced implementations) |
@stof yes ... and no. For example I consider the feature to mark a user account locked/expired/enabled (whatever you call it in your app) a very basic feature ... but it was provided in the AdvancedUserInterface. I just wanted to say: OK if you want to improve the advanced case ... but please, don't make the simple case even harder. Thanks 🙏 |
@javiereguiluz that case has already been made more "difficult" for custom user objects. The |
Pinging @symfony/deciders whether or not I should work on this for Symfony 4.2+. It's a bit too much to do in a single PR and I don't want to do only half of the proposal 😄 I'm hoping to have covered all the upgrade paths in the initial post, but feel free to spew out more possible problems. edit: seems like the deciders highlight is not working :( |
The simple case of a login form with just the The basic features of locking/enabling/whatever users has never been a simple feature in Symfony (that's why most people use FOSUserBundle). That's however completely unrelated to this RFC. |
Personally I would like to see the UserInterface (or the majority thereof) being used for the internal security process, I just would like to prevent it from being stored in the token, storing the identifier only. But something has to be created to fetch the current domain user (usually an entity), see #26971 (comment). |
Thank you for this suggestion. |
Could I get an answer? If I do not hear anything I will assume this issue is resolved or abandoned. Please get back to me <3 |
Done in #32824. |
See #40443 |
In #23508 the
AdvancedUserInterface
was deprecated and theUserChecker
was made to support theUser
specifically. When 5.0 is released, that means that theUserChecker
will effectively only work when theUser
is passed.symfony/src/Symfony/Component/Security/Core/User/UserChecker.php
Lines 31 to 37 in 97cee3a
Some facts:
User
class is not used anywhere in the core except for theLdapUserProvider
andInMemoryUserProvider
.InMemoryUserProvider
only supports theenabled
feature of theAdvancedUserInterface
.LdapUserProvider
doesn't use any of theAdvancedUserInterface
features.RFC
In this RFC I would like to propose the following things to reduce the complexity:
LdapUser
, exclusively used by theLdapUserProvider
. For BC it can extend the User for instanceof checks. Would only receive the currently used fields.InMemoryUser
, exclusively used by theInMemoryUserProvider
. For BC it can extend the User for instanceof checks. Would only receive the currently used fields.NullUserChecker
, which features 0 checks. In 5.0 this would become the defaultUserChecker
in the configuration.UserChecker
toInMemoryUserChecker
(BC:UserChecker extends InMemoryUserChecker
). This UserChecker will no longer check anything but theenabled
flag. Keep this user-checker as default in 4.x, but throw a deprecation if no user-checker is configured.User
user class and instead document thoroughly how to create your own user class and checker.UserInterface
implementation for tests only.Scenarios
I've been thinking about a few scenarios in which things will change for developers. Generally speaking, the impact should be rather small.
Using the
User
in customUserProvider
Time to fix: roughly 15~30 minutes, requires proper documentation
In this scenario, the develop will have to carefully look at which features should be kept. A custom
UserInterface
implementation will have to be provided. If any of theAdvancedUserInterface
domain-like features were used, these will have to be manually implemented, and a customUserChecker
has to be created and configured.To do:
User
Using the
InMemoryUser
andInMemoryUserProvider
Time to fix: roughly 2 minutes, proper deprecation should suffice
In this scenario, by default, the
UserChecker
would be configured by Symfony as default config. In 5.0 this would become theNullUserChecker
, which does nothing. TheInMemoryUser
would be able to define anenabled
field, which has to be checked by theInMemoryUserChecker
. To fix this, configure the right user checkerTo do:
user-checker
option in your firewall to use theInMemoryUserChecker
Using the
User
in testsTime to fix: roughly 5~30 minutes, depending on how often it's used
In this scenario, which I believe is more common, developers have used the
User
in their tests. This is also the case within Symfony. I think that it would be easiest to add aTestUser
in aTest
namespace and expose this (as opposed to tests in theTests
namespace).To do:
User
byTestUser
with the right namespaceIf I've missed any scenarios, please let me know and I will add them. The goal of this RFC is to reduce domain logic in Symfony and having no ambiguous purposes for the User and User Checker. Additionally the
NullUserChecker
will simply do nothing, which is the default case with a custom user class as of 4.1.The text was updated successfully, but these errors were encountered: