fix!: Remove legacy event dispatching Symfony's GenericEvent from 2FA Manager

Signed-off-by: Joas Schilling <coding@schilljs.com>
pull/39571/head
Joas Schilling 10 months ago
parent 1b387bb341
commit dac31ad101
No known key found for this signature in database
GPG Key ID: C400AAF20C1BB6FC

@ -37,7 +37,6 @@ use Exception;
use OC\Authentication\Exceptions\PasswordLoginForbiddenException;
use OC\Authentication\TwoFactorAuth\Manager;
use OC\Security\Bruteforce\Throttler;
use OC\User\LoginException;
use OC\User\Session;
use OCA\DAV\Connector\Sabre\Exception\PasswordLoginForbidden;
use OCA\DAV\Connector\Sabre\Exception\TooManyRequests;

@ -46,8 +46,6 @@ use OCP\ISession;
use OCP\IUser;
use OCP\Session\Exceptions\SessionNotAvailableException;
use Psr\Log\LoggerInterface;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\EventDispatcher\GenericEvent;
use function array_diff;
use function array_filter;
@ -87,9 +85,6 @@ class Manager {
/** @var IEventDispatcher */
private $dispatcher;
/** @var EventDispatcherInterface */
private $legacyDispatcher;
/** @psalm-var array<string, bool> */
private $userIsTwoFactorAuthenticated = [];
@ -102,8 +97,7 @@ class Manager {
LoggerInterface $logger,
TokenProvider $tokenProvider,
ITimeFactory $timeFactory,
IEventDispatcher $eventDispatcher,
EventDispatcherInterface $legacyDispatcher) {
IEventDispatcher $eventDispatcher) {
$this->providerLoader = $providerLoader;
$this->providerRegistry = $providerRegistry;
$this->mandatoryTwoFactor = $mandatoryTwoFactor;
@ -114,7 +108,6 @@ class Manager {
$this->tokenProvider = $tokenProvider;
$this->timeFactory = $timeFactory;
$this->dispatcher = $eventDispatcher;
$this->legacyDispatcher = $legacyDispatcher;
}
/**
@ -284,9 +277,6 @@ class Manager {
$tokenId = $token->getId();
$this->config->deleteUserValue($user->getUID(), 'login_token_2fa', (string)$tokenId);
$dispatchEvent = new GenericEvent($user, ['provider' => $provider->getDisplayName()]);
$this->legacyDispatcher->dispatch(IProvider::EVENT_SUCCESS, $dispatchEvent);
$this->dispatcher->dispatchTyped(new TwoFactorProviderForUserEnabled($user, $provider));
$this->dispatcher->dispatchTyped(new TwoFactorProviderChallengePassed($user, $provider));
@ -294,9 +284,6 @@ class Manager {
'provider' => $provider->getDisplayName(),
]);
} else {
$dispatchEvent = new GenericEvent($user, ['provider' => $provider->getDisplayName()]);
$this->legacyDispatcher->dispatch(IProvider::EVENT_FAILED, $dispatchEvent);
$this->dispatcher->dispatchTyped(new TwoFactorProviderForUserDisabled($user, $provider));
$this->dispatcher->dispatchTyped(new TwoFactorProviderChallengeFailed($user, $provider));

@ -32,17 +32,6 @@ use OCP\Template;
* @since 9.1.0
*/
interface IProvider {
/**
* @since 14.0.0
* @deprecated 22.0.0
*/
public const EVENT_SUCCESS = self::class . '::success';
/**
* @deprecated 22.0.0
*/
public const EVENT_FAILED = self::class . '::failed';
/**
* Get unique identifier of this 2FA provider
*

@ -40,7 +40,6 @@ use OCP\IUser;
use PHPUnit\Framework\MockObject\MockObject;
use Psr\Log\LoggerInterface;
use function reset;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Test\TestCase;
class ManagerTest extends TestCase {
@ -84,10 +83,7 @@ class ManagerTest extends TestCase {
private $timeFactory;
/** @var IEventDispatcher|MockObject */
private $newDispatcher;
/** @var EventDispatcherInterface|MockObject */
private $eventDispatcher;
private $dispatcher;
protected function setUp(): void {
parent::setUp();
@ -102,8 +98,7 @@ class ManagerTest extends TestCase {
$this->logger = $this->createMock(LoggerInterface::class);
$this->tokenProvider = $this->createMock(TokenProvider::class);
$this->timeFactory = $this->createMock(ITimeFactory::class);
$this->newDispatcher = $this->createMock(IEventDispatcher::class);
$this->eventDispatcher = $this->createMock(EventDispatcherInterface::class);
$this->dispatcher = $this->createMock(IEventDispatcher::class);
$this->manager = new Manager(
$this->providerLoader,
@ -115,8 +110,7 @@ class ManagerTest extends TestCase {
$this->logger,
$this->tokenProvider,
$this->timeFactory,
$this->newDispatcher,
$this->eventDispatcher
$this->dispatcher,
);
$this->fakeProvider = $this->createMock(IProvider::class);
@ -530,8 +524,7 @@ class ManagerTest extends TestCase {
$this->logger,
$this->tokenProvider,
$this->timeFactory,
$this->newDispatcher,
$this->eventDispatcher
$this->dispatcher,
])
->setMethods(['loadTwoFactorApp', 'isTwoFactorAuthenticated'])// Do not actually load the apps
->getMock();

Loading…
Cancel
Save