8000 [Security] Add authentication success sensitive event to authentication provider manager (rebase #26050) by curry684 · Pull Request #30955 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Security] Add authentication success sensitive event to authentication provider manager (rebase #26050) #30955

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Upgrade security events to 5.0 standards
  • Loading branch information
curry684 committed Apr 7, 2019
commit 05965f208da48a8a5e299aefb99af39d5214f0e2
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace Symfony\Component\Security\Core\Event;

use Symfony\Component\EventDispatcher\Event;
use Symfony\Contracts\EventDispatcher\Event;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be reverted: BC break :)

use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace Symfony\Component\Security\Core\Event;

use Symfony\Component\EventDispatcher\Event;
use Symfony\Contracts\EventDispatcher\Event;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use PHPUnit\Framework\TestCase;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\EventDispatcher\WrappedEvent;
use Symfony\Component\Security\Core\Authentication\AuthenticationProviderManager;
use Symfony\Component\Security\Core\Authentication\Provider\AuthenticationProviderInterface;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
Expand All @@ -25,6 +26,7 @@
use Symfony\Component\Security\Core\Exception\AccountStatusException;
use Symfony\Component\Security\Core\Exception\AuthenticationException;
use Symfony\Component\Security\Core\Exception\ProviderNotFoundException;
use Symfony\Contracts\EventDispatcher\Event;

class AuthenticationProviderManagerTest extends TestCase
{
Expand Down Expand Up @@ -189,13 +191,23 @@ public function testAuthenticateDispatchesAuthenticationSuccessEventsWithCredent
$providerCN = \get_class($provider);

$dispatcher = new EventDispatcher();
$dispatcher->addListener(AuthenticationEvents::AUTHENTICATION_SUCCESS_SENSITIVE, function (AuthenticationSensitiveEvent $event) use ($providerCN) {
$dispatcher->addListener(AuthenticationEvents::AUTHENTICATION_SUCCESS_SENSITIVE, function ($event) use ($providerCN) {
if (\get_class($event) === 'Symfony\Component\EventDispatcher\WrappedEvent') {
$event = $event->getWrappedEvent();
}

/** @var AuthenticationSensitiveEvent $event */
$this->assertSame($providerCN, $event->getAuthenticationProviderClassName());
$this->assertSame('bar', $event->getAuthenticationTokenPassword());
$this->assertEquals('bar', $event->getPreAuthenticationToken()->getCredentials());
$this->assertEquals('bar', $event->getAuthenticationToken()->getCredentials());
});
$dispatcher->addListener(AuthenticationEvents::AUTHENTICATION_SUCCESS, function (AuthenticationSuccessEvent $event) {
$dispatcher->addListener(AuthenticationEvents::AUTHENTICATION_SUCCESS, function ($event) {
if (\get_class($event) === 'Symfony\Component\EventDispatcher\WrappedEvent') {
$event = $event->getWrappedEvent();
}

/** @var AuthenticationSuccessEvent $event */
$this->assertEquals('', $event->getAuthenticationToken()->getCredentials());
});

Expand Down
0