-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[security] There is no user provider for user #35435
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
After more analyse, my customProvider return bad Class on method supportClass |
Hi I am having the same issue but with version 3.4.37 https://stackoverflow.com/questions/59858525/there-is-no-user-provider-for-user-symfony-3-4-37 Wen downgrading to 3.4.36 everything works fine. |
Same thing with version 3.4.37 the issue was from my custom user provider supportsClass methode returning a wrong class |
Just in case anybody is wondering, the 3.4.37 problem was also the result of an invalid supportsClass method. Looks like the older code was not properly using the method. |
Hello everybody! I am experiencing the same issue on the Symfony 4.4.3. As all other guys before me, the issue is on the method Before (fails with the described exception): public function supportsClass($class)
{
return $class === UserInterface::class;
} After (works fine): public function supportsClass($class)
{
return $class === MyCustomModel::class;
} I was checking the security component and I think that the issue is introduced in the next commit: Sincerely, I think that now it have the expected behaviour; but is breaking bad implemented custom providers. May be some one could correct my words. Cheers! |
@terox you are right, even if the last implementation is the good way and have sense to fix on 5.x, on 4.4.3 you break semserv. ping @nicolas-grekas, what do you think ? |
No opinion. Any bug fix is a potential BC break, it's never black and white. Given all reports mention bad implementations of |
you have right too |
On our side we have the problem when a Doctrine proxy class is used by security component instead of the original one, such as So |
I agree with @nicolas-grekas. Should the documentation mention or put some example that @kissifrot is commenting? I think that it could be a common issue. |
As a follow-up to my previous comment, for most cases to support the proxies and fix the user provider error you would just have to edit your public function supportsClass($class)
{
return MyUserEntity::class === $class || is_subclass_of($class, MyUserEntity::class);
} |
To get things clear: What we're seeing here is that symfony/src/Symfony/Component/Security/Http/Firewall/ContextListener.php Lines 178 to 180 in d3942cb
I think it's good to have this bug fix, but we can do better at reporting the bug. For instance, what about moving this if condition after 👇 in Symfony 5.x? symfony/src/Symfony/Component/Security/Http/Firewall/ContextListener.php Lines 182 to 185 in d3942cb
We can then improve the exception by saying something like:
And then move the if statement to it's current position in Symfony 6, probably speeding up applications with many users providers a bit. |
@nicolas-grekas this is a use-case that I have discussed with @chalasr I believe, I can't find it right now so must've been on slack as I couldn't see it in the PR or Issue. We considered it to be a bug if your logic in
That depends, it's not clear -especially in older Symfony versions- that the
This would have to be done in the same in the
So this suggestion (by moving the logic) would be a DX solution to hint people what is wrong? I would advice to do this in 3.4+ already if it's merely DX as part of this bug fix. |
I also ran into this, but think the change is a good one. I suggest that the upgrade docs for the affected versions should mention this change and the |
I'm against reverting. It revealed many broken implementations which are likely to open the door for true security holes, especially on 3.4 where changed users are not deauthenticated by default at refresh-time. |
Closing in favor of symfony/maker-bundle#532. Thanks for the report! |
@chalasr it's not so much about reverting, it's about improving the error message. Fixing the maker helps future applications, but doesn't help applications upgrading to Symfony 4.4. We should help the upgrading user to easier find this error (as "There is no user provider for this user" isn't a very good indicator to start debugging) |
What if we change this message to refer to the |
@wouterj right, thanks for clarifying. 👍 on my side |
… provider is found (wouterj) This PR was submitted for the 4.4 branch but it was merged into the 3.4 branch instead. Discussion ---------- [Security] Improved error message when no supported user provider is found | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | no | New feature? | no | Deprecations? | no | Tickets | Fix #35435 | License | MIT | Doc PR | - Commits ------- 6b2db6d Improved error message when no supported user provider is found
Symfony version(s) affected: 4.4.3
Description
After update to 4.4.3 i have a RuntimeException "There is no user provider for user"
How to reproduce
if you have custom provider update to 4.4.3
Sample
Possible Solution
Problem is on the file Symfony/Component/Security/Http/Firewall/ContextListener.php method refreshUser
Follows #35065
The text was updated successfully, but these errors were encountered: