Skip to content

Commit

Permalink
feature #49015 [Security] Added condition to always return the real A…
Browse files Browse the repository at this point in the history
…uthenticator from security events (florentdestremau)

This PR was merged into the 6.3 branch.

Discussion
----------

[Security] Added condition to always return the real Authenticator from security events

| Q             | A
| ------------- | ---
| Branch?       | 6.3
| Bug fix?      | no / maybe
| New feature?  | yes / maybe
| Deprecations? | no
| Tickets       | Fix #49010
| License       | MIT
| Doc PR        | symfony/symfony-docs#... <!-- required for new features -->

This PR aims to uniformise the `getAuthenticator` method of several security Events when using the profiler in dev environement.

Commits
-------

5e6b471 Added condition to always return the real Authenticator
  • Loading branch information
wouterj committed Feb 26, 2023
2 parents 2fc5f0a + 5e6b471 commit 3d380c9
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
namespace Symfony\Component\Security\Http\Event;

use Symfony\Component\Security\Http\Authenticator\AuthenticatorInterface;
use Symfony\Component\Security\Http\Authenticator\Debug\TraceableAuthenticator;
use Symfony\Component\Security\Http\Authenticator\Passport\Passport;
use Symfony\Contracts\EventDispatcher\Event;

Expand All @@ -37,7 +38,7 @@ public function __construct(AuthenticatorInterface $authenticator, Passport $pas

public function getAuthenticator(): AuthenticatorInterface
{
return $this->authenticator;
return $this->authenticator instanceof TraceableAuthenticator ? $this->authenticator->getAuthenticator() : $this->authenticator;
}

public function getPassport(): Passport
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Security\Core\Exception\AuthenticationException;
use Symfony\Component\Security\Http\Authenticator\AuthenticatorInterface;
use Symfony\Component\Security\Http\Authenticator\Debug\TraceableAuthenticator;
use Symfony\Component\Security\Http\Authenticator\Passport\Passport;
use Symfony\Contracts\EventDispatcher\Event;

Expand Down Expand Up @@ -52,7 +53,7 @@ public function getException(): AuthenticationException

public function getAuthenticator(): AuthenticatorInterface
{
return $this->authenticator;
return $this->authenticator instanceof TraceableAuthenticator ? $this->authenticator->getAuthenticator() : $this->authenticator;
}

public function getFirewallName(): string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Component\Security\Http\Authenticator\AuthenticatorInterface;
use Symfony\Component\Security\Http\Authenticator\Debug\TraceableAuthenticator;
use Symfony\Component\Security\Http\Authenticator\Passport\Passport;
use Symfony\Contracts\EventDispatcher\Event;

Expand Down Expand Up @@ -50,7 +51,7 @@ public function __construct(AuthenticatorInterface $authenticator, Passport $pas

public function getAuthenticator(): AuthenticatorInterface
{
return $this->authenticator;
return $this->authenticator instanceof TraceableAuthenticator ? $this->authenticator->getAuthenticator() : $this->authenticator;
}

public function getPassport(): Passport
Expand Down

0 comments on commit 3d380c9

Please sign in to comment.