From 21c303009259573f78629a7f678f6f2c3369e674 Mon Sep 17 00:00:00 2001 From: Enrico Schultz Date: Mon, 26 Nov 2018 08:11:22 +0100 Subject: [PATCH] [Security] defer log message in guard authenticator prevent an unneccessary log message if the guard authenticator does not support the current request --- .../Firewall/GuardAuthenticationListener.php | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Component/Security/Guard/Firewall/GuardAuthenticationListener.php b/src/Symfony/Component/Security/Guard/Firewall/GuardAuthenticationListener.php index 02864f372542d..2df09577bf0a6 100644 --- a/src/Symfony/Component/Security/Guard/Firewall/GuardAuthenticationListener.php +++ b/src/Symfony/Component/Security/Guard/Firewall/GuardAuthenticationListener.php @@ -97,13 +97,17 @@ private function executeGuardAuthenticator($uniqueGuardKey, GuardAuthenticatorIn { $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 @@ private function executeGuardAuthenticator($uniqueGuardKey, GuardAuthenticatorIn $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);