merged branch xkobal/master (PR #8830)
This PR was submitted for the master branch but it was merged into the 2.2 branch instead (closes #8830). Discussion ---------- clearToken exception is thrown at wrong place. The PR https://github.com/symfony/symfony/pull/8528 has added a problem when logger is enabled. The log message for clearToken exception throw actually a fatal error because $failed doesn't exist in clearToken method. I have moved the log message to the handle method. Commits ------- 701c25b clearToken exception is thrown at wrong place.
This commit is contained in:
commit
c0f56f8353
@ -63,7 +63,7 @@ abstract class AbstractPreAuthenticatedListener implements ListenerInterface
|
|||||||
try {
|
try {
|
||||||
list($user, $credentials) = $this->getPreAuthenticatedData($request);
|
list($user, $credentials) = $this->getPreAuthenticatedData($request);
|
||||||
} catch (BadCredentialsException $exception) {
|
} catch (BadCredentialsException $exception) {
|
||||||
$this->clearToken();
|
$this->clearToken($exception);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -91,21 +91,23 @@ abstract class AbstractPreAuthenticatedListener implements ListenerInterface
|
|||||||
$this->dispatcher->dispatch(SecurityEvents::INTERACTIVE_LOGIN, $loginEvent);
|
$this->dispatcher->dispatch(SecurityEvents::INTERACTIVE_LOGIN, $loginEvent);
|
||||||
}
|
}
|
||||||
} catch (AuthenticationException $failed) {
|
} catch (AuthenticationException $failed) {
|
||||||
$this->clearToken();
|
$this->clearToken($failed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clears a PreAuthenticatedToken for this provider (if present)
|
* Clears a PreAuthenticatedToken for this provider (if present)
|
||||||
|
*
|
||||||
|
* @param AuthenticationException $exception
|
||||||
*/
|
*/
|
||||||
protected function clearToken()
|
private function clearToken(AuthenticationException $exception)
|
||||||
{
|
{
|
||||||
$token = $this->securityContext->getToken();
|
$token = $this->securityContext->getToken();
|
||||||
if ($token instanceof PreAuthenticatedToken && $this->providerKey === $token->getProviderKey()) {
|
if ($token instanceof PreAuthenticatedToken && $this->providerKey === $token->getProviderKey()) {
|
||||||
$this->securityContext->setToken(null);
|
$this->securityContext->setToken(null);
|
||||||
|
|
||||||
if (null !== $this->logger) {
|
if (null !== $this->logger) {
|
||||||
$this->logger->info(sprintf("Cleared security context due to exception: %s", $failed->getMessage()));
|
$this->logger->info(sprintf("Cleared security context due to exception: %s", $exception->getMessage()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user