[Security] defer log message in guard authenticator

prevent an unneccessary log message if the guard authenticator does not support the current request
This commit is contained in:
Enrico Schultz 2018-11-26 08:11:22 +01:00 committed by Robin Chalas
parent 02b3510a11
commit 21c3030092

View File

@ -97,13 +97,17 @@ class GuardAuthenticationListener implements ListenerInterface
{
$request = $event->getRequest();
try {
if (null !== $this->logger) {
$this->logger->debug('Calling getCredentials() on guard authenticator.', array('firewall_key' => $this->providerKey, 'authenticator' => \get_class($guardAuthenticator)));
}
// abort the execution of the authenticator if it doesn't support the request
if ($guardAuthenticator instanceof AuthenticatorInterface) {
if (null !== $this->logger) {
$this->logger->debug('Checking support on guard authenticator.', array('firewall_key' => $this->providerKey, 'authenticator' => \get_class($guardAuthenticator)));
}
if (!$guardAuthenticator->supports($request)) {
if (null !== $this->logger) {
$this->logger->debug('Guard authenticator does not support the request.', array('firewall_key' => $this->providerKey, 'authenticator' => \get_class($guardAuthenticator)));
}
return;
}
// as there was a support for given request,
@ -114,6 +118,10 @@ class GuardAuthenticationListener implements ListenerInterface
$credentialsCanBeNull = true;
}
if (null !== $this->logger) {
$this->logger->debug('Calling getCredentials() on guard authenticator.', array('firewall_key' => $this->providerKey, 'authenticator' => \get_class($guardAuthenticator)));
}
// allow the authenticator to fetch authentication info from the request
$credentials = $guardAuthenticator->getCredentials($request);