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
bug #21865 [Security] context listener: hardening user provider handling (xabbuh)
This PR was merged into the 2.7 branch.
Discussion
----------
[Security] context listener: hardening user provider handling
| Q | A
| ------------- | ---
| Branch? | 2.7
| Bug fix? | yes
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | #4498
| License | MIT
| Doc PR |
After the wrong fix in #21791 this is the second attempt to solve #4498. If more than one user provider support the user for the current context, all of them will be applied instead of returning prematurely when the first user provider does not find the logged in user.
Commits
-------
0fb0929 context listener: hardening user provider handling
Copy file name to clipboardExpand all lines: src/Symfony/Component/Security/Http/Firewall/ContextListener.php
+7-1Lines changed: 7 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -150,6 +150,8 @@ protected function refreshUser(TokenInterface $token)
150
150
return$token;
151
151
}
152
152
153
+
$userNotFoundByProvider = false;
154
+
153
155
foreach ($this->userProvidersas$provider) {
154
156
try {
155
157
$refreshedUser = $provider->refreshUser($user);
@@ -167,10 +169,14 @@ protected function refreshUser(TokenInterface $token)
167
169
$this->logger->warning('Username could not be found in the selected user provider.', array('username' => $e->getUsername(), 'provider' => get_class($provider)));
168
170
}
169
171
170
-
return;
172
+
$userNotFoundByProvider = true;
171
173
}
172
174
}
173
175
176
+
if ($userNotFoundByProvider) {
177
+
return;
178
+
}
179
+
174
180
thrownew \RuntimeException(sprintf('There is no user provider for user "%s".', get_class($user)));
0 commit comments