Skip to content

Commit bdf8cd6

Browse files
committed
Renamed VerifyAuthenticatorCredentialsEvent to CheckPassportEvent
1 parent f606922 commit bdf8cd6

10 files changed

+76
-42
lines changed

Authentication/AuthenticatorManager.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@
2626
use Symfony\Component\Security\Http\Authenticator\Passport\Badge\BadgeInterface;
2727
use Symfony\Component\Security\Http\Authenticator\Passport\PassportInterface;
2828
use Symfony\Component\Security\Http\Authenticator\Passport\SelfValidatingPassport;
29+
use Symfony\Component\Security\Http\Event\CheckPassportEvent;
2930
use Symfony\Component\Security\Http\Event\InteractiveLoginEvent;
3031
use Symfony\Component\Security\Http\Event\LoginFailureEvent;
3132
use Symfony\Component\Security\Http\Event\LoginSuccessEvent;
32-
use Symfony\Component\Security\Http\Event\VerifyAuthenticatorCredentialsEvent;
3333
use Symfony\Component\Security\Http\SecurityEvents;
3434
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
3535

@@ -159,7 +159,7 @@ private function executeAuthenticator(AuthenticatorInterface $authenticator, Req
159159
$passport = $authenticator->authenticate($request);
160160

161161
// check the passport (e.g. password checking)
162-
$event = new VerifyAuthenticatorCredentialsEvent($authenticator, $passport);
162+
$event = new CheckPassportEvent($authenticator, $passport);
163163
$this->eventDispatcher->dispatch($event);
164164

165165
// check if all badges are resolved

Authenticator/Token/PostAuthenticationToken.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
<?php
22

3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
312
namespace Symfony\Component\Security\Http\Authenticator\Token;
413

514
use Symfony\Component\Security\Core\Authentication\Token\AbstractToken;

Event/VerifyAuthenticatorCredentialsEvent.php renamed to Event/CheckPassportEvent.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
11
<?php
22

3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
312
namespace Symfony\Component\Security\Http\Event;
413

5-
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
6-
use Symfony\Component\Security\Core\User\UserInterface;
714
use Symfony\Component\Security\Http\Authenticator\AuthenticatorInterface;
815
use Symfony\Component\Security\Http\Authenticator\Passport\PassportInterface;
916
use Symfony\Contracts\EventDispatcher\Event;
@@ -17,7 +24,7 @@
1724
*
1825
* @author Wouter de Jong <wouter@wouterj.nl>
1926
*/
20-
class VerifyAuthenticatorCredentialsEvent extends Event
27+
class CheckPassportEvent extends Event
2128
{
2229
private $authenticator;
2330
private $passport;

EventListener/VerifyAuthenticatorCredentialsListener.php renamed to EventListener/CheckCredentialsListener.php

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
<?php
22

3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
312
namespace Symfony\Component\Security\Http\EventListener;
413

514
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
@@ -8,7 +17,7 @@
817
use Symfony\Component\Security\Http\Authenticator\Passport\Credentials\CustomCredentials;
918
use Symfony\Component\Security\Http\Authenticator\Passport\Credentials\PasswordCredentials;
1019
use Symfony\Component\Security\Http\Authenticator\Passport\UserPassportInterface;
11-
use Symfony\Component\Security\Http\Event\VerifyAuthenticatorCredentialsEvent;
20+
use Symfony\Component\Security\Http\Event\CheckPassportEvent;
1221

1322
/**
1423
* This listeners uses the interfaces of authenticators to
@@ -19,7 +28,7 @@
1928
* @final
2029
* @experimental in 5.1
2130
*/
22-
class VerifyAuthenticatorCredentialsListener implements EventSubscriberInterface
31+
class CheckCredentialsListener implements EventSubscriberInterface
2332
{
2433
private $encoderFactory;
2534

@@ -28,7 +37,7 @@ public function __construct(EncoderFactoryInterface $encoderFactory)
2837
$this->encoderFactory = $encoderFactory;
2938
}
3039

31-
public function onAuthenticating(VerifyAuthenticatorCredentialsEvent $event): void
40+
public function checkPassport(CheckPassportEvent $event): void
3241
{
3342
$passport = $event->getPassport();
3443
if ($passport instanceof UserPassportInterface && $passport->hasBadge(PasswordCredentials::class)) {
@@ -74,6 +83,6 @@ public function onAuthenticating(VerifyAuthenticatorCredentialsEvent $event): vo
7483

7584
public static function getSubscribedEvents(): array
7685
{
77-
return [VerifyAuthenticatorCredentialsEvent::class => ['onAuthenticating', 128]];
86+
return [CheckPassportEvent::class => 'checkPassport'];
7887
}
7988
}

EventListener/CsrfProtectionListener.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
use Symfony\Component\Security\Csrf\CsrfToken;
1717
use Symfony\Component\Security\Csrf\CsrfTokenManagerInterface;
1818
use Symfony\Component\Security\Http\Authenticator\Passport\Badge\CsrfTokenBadge;
19-
use Symfony\Component\Security\Http\Event\VerifyAuthenticatorCredentialsEvent;
19+
use Symfony\Component\Security\Http\Event\CheckPassportEvent;
2020

2121
/**
2222
* @author Wouter de Jong <wouter@wouterj.nl>
@@ -33,7 +33,7 @@ public function __construct(CsrfTokenManagerInterface $csrfTokenManager)
3333
$this->csrfTokenManager = $csrfTokenManager;
3434
}
3535

36-
public function verifyCredentials(VerifyAuthenticatorCredentialsEvent $event): void
36+
public function checkPassport(CheckPassportEvent $event): void
3737
{
3838
$passport = $event->getPassport();
3939
if (!$passport->hasBadge(CsrfTokenBadge::class)) {
@@ -57,6 +57,6 @@ public function verifyCredentials(VerifyAuthenticatorCredentialsEvent $event): v
5757

5858
public static function getSubscribedEvents(): array
5959
{
60-
return [VerifyAuthenticatorCredentialsEvent::class => ['verifyCredentials', 256]];
60+
return [CheckPassportEvent::class => ['checkPassport', 128]];
6161
}
6262
}

EventListener/UserCheckerListener.php

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,22 @@
11
<?php
22

3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
312
namespace Symfony\Component\Security\Http\EventListener;
413

514
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
615
use Symfony\Component\Security\Core\User\UserCheckerInterface;
716
use Symfony\Component\Security\Http\Authenticator\Passport\Badge\PreAuthenticatedUserBadge;
817
use Symfony\Component\Security\Http\Authenticator\Passport\UserPassportInterface;
18+
use Symfony\Component\Security\Http\Event\CheckPassportEvent;
919
use Symfony\Component\Security\Http\Event\LoginSuccessEvent;
10-
use Symfony\Component\Security\Http\Event\VerifyAuthenticatorCredentialsEvent;
1120

1221
/**
1322
* @author Wouter de Jong <wouter@wouterj.nl>
@@ -24,7 +33,7 @@ public function __construct(UserCheckerInterface $userChecker)
2433
$this->userChecker = $userChecker;
2534
}
2635

27-
public function preCredentialsVerification(VerifyAuthenticatorCredentialsEvent $event): void
36+
public function preCheckCredentials(CheckPassportEvent $event): void
2837
{
2938
$passport = $event->getPassport();
3039
if (!$passport instanceof UserPassportInterface || $passport->hasBadge(PreAuthenticatedUserBadge::class)) {
@@ -34,7 +43,7 @@ public function preCredentialsVerification(VerifyAuthenticatorCredentialsEvent $
3443
$this->userChecker->checkPreAuth($passport->getUser());
3544
}
3645

37-
public function postCredentialsVerification(LoginSuccessEvent $event): void
46+
public function postCheckCredentials(LoginSuccessEvent $event): void
3847
{
3948
$passport = $event->getPassport();
4049
if (!$passport instanceof UserPassportInterface || null === $passport->getUser()) {
@@ -47,8 +56,8 @@ public function postCredentialsVerification(LoginSuccessEvent $event): void
4756
public static function getSubscribedEvents(): array
4857
{
4958
return [
50-
VerifyAuthenticatorCredentialsEvent::class => [['preCredentialsVerification', 256]],
51-
LoginSuccessEvent::class => ['postCredentialsVerification', 256],
59+
CheckPassportEvent::class => ['preCheckCredentials', 256],
60+
LoginSuccessEvent::class => ['postCheckCredentials', 256],
5261
];
5362
}
5463
}

Tests/Authentication/AuthenticatorManagerTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
use Symfony\Component\Security\Http\Authenticator\Passport\Credentials\PasswordCredentials;
2525
use Symfony\Component\Security\Http\Authenticator\Passport\Passport;
2626
use Symfony\Component\Security\Http\Authenticator\Passport\SelfValidatingPassport;
27-
use Symfony\Component\Security\Http\Event\VerifyAuthenticatorCredentialsEvent;
27+
use Symfony\Component\Security\Http\Event\CheckPassportEvent;
2828

2929
class AuthenticatorManagerTest extends TestCase
3030
{
@@ -95,7 +95,7 @@ public function testAuthenticateRequest($matchingAuthenticatorIndex)
9595
$matchingAuthenticator->expects($this->any())->method('authenticate')->willReturn(new SelfValidatingPassport($this->user));
9696

9797
$listenerCalled = false;
98-
$this->eventDispatcher->addListener(VerifyAuthenticatorCredentialsEvent::class, function (VerifyAuthenticatorCredentialsEvent $event) use (&$listenerCalled, $matchingAuthenticator) {
98+
$this->eventDispatcher->addListener(CheckPassportEvent::class, function (CheckPassportEvent $event) use (&$listenerCalled, $matchingAuthenticator) {
9999
if ($event->getAuthenticator() === $matchingAuthenticator && $event->getPassport()->getUser() === $this->user) {
100100
$listenerCalled = true;
101101
}
@@ -106,7 +106,7 @@ public function testAuthenticateRequest($matchingAuthenticatorIndex)
106106

107107
$manager = $this->createManager($authenticators);
108108
$this->assertNull($manager->authenticateRequest($this->request));
109-
$this->assertTrue($listenerCalled, 'The VerifyAuthenticatorCredentialsEvent listener is not called');
109+
$this->assertTrue($listenerCalled, 'The CheckPassportEvent listener is not called');
110110
}
111111

112112
public function provideMatchingAuthenticatorIndex()

Tests/EventListener/VerifyAuthenticatorCredentialsListenerTest.php renamed to Tests/EventListener/CheckCredentialsListenerTest.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@
2121
use Symfony\Component\Security\Http\Authenticator\Passport\Credentials\PasswordCredentials;
2222
use Symfony\Component\Security\Http\Authenticator\Passport\Passport;
2323
use Symfony\Component\Security\Http\Authenticator\Passport\SelfValidatingPassport;
24-
use Symfony\Component\Security\Http\Event\VerifyAuthenticatorCredentialsEvent;
25-
use Symfony\Component\Security\Http\EventListener\VerifyAuthenticatorCredentialsListener;
24+
use Symfony\Component\Security\Http\Event\CheckPassportEvent;
25+
use Symfony\Component\Security\Http\EventListener\CheckCredentialsListener;
2626

27-
class VerifyAuthenticatorCredentialsListenerTest extends TestCase
27+
class CheckCredentialsListenerTest extends TestCase
2828
{
2929
private $encoderFactory;
3030
private $listener;
@@ -33,7 +33,7 @@ class VerifyAuthenticatorCredentialsListenerTest extends TestCase
3333
protected function setUp(): void
3434
{
3535
$this->encoderFactory = $this->createMock(EncoderFactoryInterface::class);
36-
$this->listener = new VerifyAuthenticatorCredentialsListener($this->encoderFactory);
36+
$this->listener = new CheckCredentialsListener($this->encoderFactory);
3737
$this->user = new User('wouter', 'encoded-password');
3838
}
3939

@@ -53,7 +53,7 @@ public function testPasswordAuthenticated($password, $passwordValid, $result)
5353
}
5454

5555
$credentials = new PasswordCredentials($password);
56-
$this->listener->onAuthenticating($this->createEvent(new Passport($this->user, $credentials)));
56+
$this->listener->checkPassport($this->createEvent(new Passport($this->user, $credentials)));
5757

5858
if (true === $result) {
5959
$this->assertTrue($credentials->isResolved());
@@ -74,7 +74,7 @@ public function testEmptyPassword()
7474
$this->encoderFactory->expects($this->never())->method('getEncoder');
7575

7676
$event = $this->createEvent(new Passport($this->user, new PasswordCredentials('')));
77-
$this->listener->onAuthenticating($event);
77+
$this->listener->checkPassport($event);
7878
}
7979

8080
/**
@@ -91,7 +91,7 @@ public function testCustomAuthenticated($result)
9191
$credentials = new CustomCredentials(function () use ($result) {
9292
return $result;
9393
}, ['password' => 'foo']);
94-
$this->listener->onAuthenticating($this->createEvent(new Passport($this->user, $credentials)));
94+
$this->listener->checkPassport($this->createEvent(new Passport($this->user, $credentials)));
9595

9696
if (true === $result) {
9797
$this->assertTrue($credentials->isResolved());
@@ -109,11 +109,11 @@ public function testNoCredentialsBadgeProvided()
109109
$this->encoderFactory->expects($this->never())->method('getEncoder');
110110

111111
$event = $this->createEvent(new SelfValidatingPassport($this->user));
112-
$this->listener->onAuthenticating($event);
112+
$this->listener->checkPassport($event);
113113
}
114114

115115
private function createEvent($passport)
116116
{
117-
return new VerifyAuthenticatorCredentialsEvent($this->createMock(AuthenticatorInterface::class), $passport);
117+
return new CheckPassportEvent($this->createMock(AuthenticatorInterface::class), $passport);
118118
}
119119
}

Tests/EventListener/CsrfProtectionListenerTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
use Symfony\Component\Security\Http\Authenticator\AuthenticatorInterface;
2020
use Symfony\Component\Security\Http\Authenticator\Passport\Badge\CsrfTokenBadge;
2121
use Symfony\Component\Security\Http\Authenticator\Passport\SelfValidatingPassport;
22-
use Symfony\Component\Security\Http\Event\VerifyAuthenticatorCredentialsEvent;
22+
use Symfony\Component\Security\Http\Event\CheckPassportEvent;
2323
use Symfony\Component\Security\Http\EventListener\CsrfProtectionListener;
2424

2525
class CsrfProtectionListenerTest extends TestCase
@@ -38,7 +38,7 @@ public function testNoCsrfTokenBadge()
3838
$this->csrfTokenManager->expects($this->never())->method('isTokenValid');
3939

4040
$event = $this->createEvent($this->createPassport(null));
41-
$this->listener->verifyCredentials($event);
41+
$this->listener->checkPassport($event);
4242
}
4343

4444
public function testValidCsrfToken()
@@ -49,7 +49,7 @@ public function testValidCsrfToken()
4949
->willReturn(true);
5050

5151
$event = $this->createEvent($this->createPassport(new CsrfTokenBadge('authenticator_token_id', 'abc123')));
52-
$this->listener->verifyCredentials($event);
52+
$this->listener->checkPassport($event);
5353

5454
$this->expectNotToPerformAssertions();
5555
}
@@ -65,12 +65,12 @@ public function testInvalidCsrfToken()
6565
->willReturn(false);
6666

6767
$event = $this->createEvent($this->createPassport(new CsrfTokenBadge('authenticator_token_id', 'abc123')));
68-
$this->listener->verifyCredentials($event);
68+
$this->listener->checkPassport($event);
6969
}
7070

7171
private function createEvent($passport)
7272
{
73-
return new VerifyAuthenticatorCredentialsEvent($this->createMock(AuthenticatorInterface::class), $passport);
73+
return new CheckPassportEvent($this->createMock(AuthenticatorInterface::class), $passport);
7474
}
7575

7676
private function createPassport(?CsrfTokenBadge $badge)

Tests/EventListener/UserCheckerListenerTest.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
use Symfony\Component\Security\Http\Authenticator\Passport\Badge\PreAuthenticatedUserBadge;
2121
use Symfony\Component\Security\Http\Authenticator\Passport\PassportInterface;
2222
use Symfony\Component\Security\Http\Authenticator\Passport\SelfValidatingPassport;
23+
use Symfony\Component\Security\Http\Event\CheckPassportEvent;
2324
use Symfony\Component\Security\Http\Event\LoginSuccessEvent;
24-
use Symfony\Component\Security\Http\Event\VerifyAuthenticatorCredentialsEvent;
2525
use Symfony\Component\Security\Http\EventListener\UserCheckerListener;
2626

2727
class UserCheckerListenerTest extends TestCase
@@ -41,44 +41,44 @@ public function testPreAuth()
4141
{
4242
$this->userChecker->expects($this->once())->method('checkPreAuth')->with($this->user);
4343

44-
$this->listener->preCredentialsVerification($this->createVerifyAuthenticatorCredentialsEvent());
44+
$this->listener->preCheckCredentials($this->createCheckPassportEvent());
4545
}
4646

4747
public function testPreAuthNoUser()
4848
{
4949
$this->userChecker->expects($this->never())->method('checkPreAuth');
5050

51-
$this->listener->preCredentialsVerification($this->createVerifyAuthenticatorCredentialsEvent($this->createMock(PassportInterface::class)));
51+
$this->listener->preCheckCredentials($this->createCheckPassportEvent($this->createMock(PassportInterface::class)));
5252
}
5353

5454
public function testPreAuthenticatedBadge()
5555
{
5656
$this->userChecker->expects($this->never())->method('checkPreAuth');
5757

58-
$this->listener->preCredentialsVerification($this->createVerifyAuthenticatorCredentialsEvent(new SelfValidatingPassport($this->user, [new PreAuthenticatedUserBadge()])));
58+
$this->listener->preCheckCredentials($this->createCheckPassportEvent(new SelfValidatingPassport($this->user, [new PreAuthenticatedUserBadge()])));
5959
}
6060

6161
public function testPostAuthValidCredentials()
6262
{
6363
$this->userChecker->expects($this->once())->method('checkPostAuth')->with($this->user);
6464

65-
$this->listener->postCredentialsVerification($this->createLoginSuccessEvent());
65+
$this->listener->postCheckCredentials($this->createLoginSuccessEvent());
6666
}
6767

6868
public function testPostAuthNoUser()
6969
{
7070
$this->userChecker->expects($this->never())->method('checkPostAuth');
7171

72-
$this->listener->postCredentialsVerification($this->createLoginSuccessEvent($this->createMock(PassportInterface::class)));
72+
$this->listener->postCheckCredentials($this->createLoginSuccessEvent($this->createMock(PassportInterface::class)));
7373
}
7474

75-
private function createVerifyAuthenticatorCredentialsEvent($passport = null)
75+
private function createCheckPassportEvent($passport = null)
7676
{
7777
if (null === $passport) {
7878
$passport = new SelfValidatingPassport($this->user);
7979
}
8080

81-
return new VerifyAuthenticatorCredentialsEvent($this->createMock(AuthenticatorInterface::class), $passport);
81+
return new CheckPassportEvent($this->createMock(AuthenticatorInterface::class), $passport);
8282
}
8383

8484
private function createLoginSuccessEvent($passport = null)

0 commit comments

Comments
 (0)