Skip to content
This repository was archived by the owner on May 31, 2024. It is now read-only.

Commit 9b1df0a

Browse files
eschultz-magixRobin Chalas
authored andcommitted
[Security] defer log message in guard authenticator
prevent an unneccessary log message if the guard authenticator does not support the current request
1 parent ee26f3b commit 9b1df0a

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

Guard/Firewall/GuardAuthenticationListener.php

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,17 @@ private function executeGuardAuthenticator($uniqueGuardKey, GuardAuthenticatorIn
9797
{
9898
$request = $event->getRequest();
9999
try {
100-
if (null !== $this->logger) {
101-
$this->logger->debug('Calling getCredentials() on guard authenticator.', array('firewall_key' => $this->providerKey, 'authenticator' => \get_class($guardAuthenticator)));
102-
}
103-
104100
// abort the execution of the authenticator if it doesn't support the request
105101
if ($guardAuthenticator instanceof AuthenticatorInterface) {
102+
if (null !== $this->logger) {
103+
$this->logger->debug('Checking support on guard authenticator.', array('firewall_key' => $this->providerKey, 'authenticator' => \get_class($guardAuthenticator)));
104+
}
105+
106106
if (!$guardAuthenticator->supports($request)) {
107+
if (null !== $this->logger) {
108+
$this->logger->debug('Guard authenticator does not support the request.', array('firewall_key' => $this->providerKey, 'authenticator' => \get_class($guardAuthenticator)));
109+
}
110+
107111
return;
108112
}
109113
// as there was a support for given request,
@@ -114,6 +118,10 @@ private function executeGuardAuthenticator($uniqueGuardKey, GuardAuthenticatorIn
114118
$credentialsCanBeNull = true;
115119
}
116120

121+
if (null !== $this->logger) {
122+
$this->logger->debug('Calling getCredentials() on guard authenticator.', array('firewall_key' => $this->providerKey, 'authenticator' => \get_class($guardAuthenticator)));
123+
}
124+
117125
// allow the authenticator to fetch authentication info from the request
118126
$credentials = $guardAuthenticator->getCredentials($request);
119127

0 commit comments

Comments
 (0)