Skip to content

Commit d23d206

Browse files
committed
feature #49015 [Security] Added condition to always return the real Authenticator 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 ------- 5e6b471a15 Added condition to always return the real Authenticator
2 parents 2dfe2cc + 6c32817 commit d23d206

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

Event/CheckPassportEvent.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Component\Security\Http\Event;
1313

1414
use Symfony\Component\Security\Http\Authenticator\AuthenticatorInterface;
15+
use Symfony\Component\Security\Http\Authenticator\Debug\TraceableAuthenticator;
1516
use Symfony\Component\Security\Http\Authenticator\Passport\Passport;
1617
use Symfony\Contracts\EventDispatcher\Event;
1718

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

3839
public function getAuthenticator(): AuthenticatorInterface
3940
{
40-
return $this->authenticator;
41+
return $this->authenticator instanceof TraceableAuthenticator ? $this->authenticator->getAuthenticator() : $this->authenticator;
4142
}
4243

4344
public function getPassport(): Passport

Event/LoginFailureEvent.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Symfony\Component\HttpFoundation\Response;
1616
use Symfony\Component\Security\Core\Exception\AuthenticationException;
1717
use Symfony\Component\Security\Http\Authenticator\AuthenticatorInterface;
18+
use Symfony\Component\Security\Http\Authenticator\Debug\TraceableAuthenticator;
1819
use Symfony\Component\Security\Http\Authenticator\Passport\Passport;
1920
use Symfony\Contracts\EventDispatcher\Event;
2021

@@ -52,7 +53,7 @@ public function getException(): AuthenticationException
5253

5354
public function getAuthenticator(): AuthenticatorInterface
5455
{
55-
return $this->authenticator;
56+
return $this->authenticator instanceof TraceableAuthenticator ? $this->authenticator->getAuthenticator() : $this->authenticator;
5657
}
5758

5859
public function getFirewallName(): string

Event/LoginSuccessEvent.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
1717
use Symfony\Component\Security\Core\User\UserInterface;
1818
use Symfony\Component\Security\Http\Authenticator\AuthenticatorInterface;
19+
use Symfony\Component\Security\Http\Authenticator\Debug\TraceableAuthenticator;
1920
use Symfony\Component\Security\Http\Authenticator\Passport\Passport;
2021
use Symfony\Contracts\EventDispatcher\Event;
2122

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

5152
public function getAuthenticator(): AuthenticatorInterface
5253
{
53-
return $this->authenticator;
54+
return $this->authenticator instanceof TraceableAuthenticator ? $this->authenticator->getAuthenticator() : $this->authenticator;
5455
}
5556

5657
public function getPassport(): Passport

0 commit comments

Comments
 (0)