Skip to content

Commit

Permalink
bug #29323 [Security] defer log message in guard authenticator (eschu…
Browse files Browse the repository at this point in the history
…ltz-magix)

This PR was merged into the 3.4 branch.

Discussion
----------

[Security] defer log message in guard authenticator

prevent an unnecessary log message if the guard authenticator does not support the current request

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

This PR defers log messages about "getCredentials()" method calls if more than one guard authentication provider is used. The method is only called if the provider supports the request. The log message may be confusing during development.

Commits
-------

21c3030 [Security] defer log message in guard authenticator
  • Loading branch information
fabpot committed Dec 10, 2018
2 parents 02b3510 + 21c3030 commit 3ee6f1d
Showing 1 changed file with 12 additions and 4 deletions.
Expand Up @@ -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,
Expand All @@ -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);

Expand Down

0 comments on commit 3ee6f1d

Please sign in to comment.