From eee9f1eec417c9bb976046e4114d3df943da62e1 Mon Sep 17 00:00:00 2001 From: Côme Chilliet Date: Thu, 4 Jan 2024 12:20:14 +0100 Subject: Always catch OCP versions of authentication exceptions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit And always throw OC versions for BC Signed-off-by: Côme Chilliet --- core/Controller/AppPasswordController.php | 2 +- core/Controller/ClientFlowLoginController.php | 5 +++-- core/Controller/ClientFlowLoginV2Controller.php | 5 +++-- core/Controller/WipeController.php | 2 +- core/Service/LoginFlowV2Service.php | 2 +- 5 files changed, 9 insertions(+), 7 deletions(-) (limited to 'core') diff --git a/core/Controller/AppPasswordController.php b/core/Controller/AppPasswordController.php index 205381e83c1..a4b7791997a 100644 --- a/core/Controller/AppPasswordController.php +++ b/core/Controller/AppPasswordController.php @@ -29,13 +29,13 @@ declare(strict_types=1); namespace OC\Core\Controller; use OC\Authentication\Events\AppPasswordCreatedEvent; -use OC\Authentication\Exceptions\InvalidTokenException; use OC\Authentication\Token\IProvider; use OC\Authentication\Token\IToken; use OCP\AppFramework\Http; use OCP\AppFramework\Http\DataResponse; use OCP\AppFramework\OCS\OCSForbiddenException; use OCP\Authentication\Exceptions\CredentialsUnavailableException; +use OCP\Authentication\Exceptions\InvalidTokenException; use OCP\Authentication\Exceptions\PasswordUnavailableException; use OCP\Authentication\LoginCredentials\IStore; use OCP\EventDispatcher\IEventDispatcher; diff --git a/core/Controller/ClientFlowLoginController.php b/core/Controller/ClientFlowLoginController.php index 07a78ba368b..57f57bbf887 100644 --- a/core/Controller/ClientFlowLoginController.php +++ b/core/Controller/ClientFlowLoginController.php @@ -33,7 +33,7 @@ namespace OC\Core\Controller; use OC\Authentication\Events\AppPasswordCreatedEvent; -use OC\Authentication\Exceptions\InvalidTokenException; +use OC\Authentication\Exceptions\InvalidTokenException as OcInvalidTokenException; use OC\Authentication\Exceptions\PasswordlessTokenException; use OC\Authentication\Token\IProvider; use OC\Authentication\Token\IToken; @@ -47,6 +47,7 @@ use OCP\AppFramework\Http\Attribute\UseSession; use OCP\AppFramework\Http\Response; use OCP\AppFramework\Http\StandaloneTemplateResponse; use OCP\AppFramework\Utility\ITimeFactory; +use OCP\Authentication\Exceptions\InvalidTokenException; use OCP\Defaults; use OCP\EventDispatcher\IEventDispatcher; use OCP\IL10N; @@ -331,7 +332,7 @@ class ClientFlowLoginController extends Controller { try { $token = $this->tokenProvider->getToken($password); if ($token->getLoginName() !== $user) { - throw new InvalidTokenException('login name does not match'); + throw new OcInvalidTokenException('login name does not match'); } } catch (InvalidTokenException $e) { $response = new StandaloneTemplateResponse( diff --git a/core/Controller/ClientFlowLoginV2Controller.php b/core/Controller/ClientFlowLoginV2Controller.php index 8aafabf9892..df522096272 100644 --- a/core/Controller/ClientFlowLoginV2Controller.php +++ b/core/Controller/ClientFlowLoginV2Controller.php @@ -27,7 +27,7 @@ declare(strict_types=1); */ namespace OC\Core\Controller; -use OC\Authentication\Exceptions\InvalidTokenException; +use OC\Authentication\Exceptions\InvalidTokenException as OcInvalidTokenException; use OC\Core\Db\LoginFlowV2; use OC\Core\Exception\LoginFlowV2NotFoundException; use OC\Core\Service\LoginFlowV2Service; @@ -40,6 +40,7 @@ use OCP\AppFramework\Http\JSONResponse; use OCP\AppFramework\Http\RedirectResponse; use OCP\AppFramework\Http\Response; use OCP\AppFramework\Http\StandaloneTemplateResponse; +use OCP\Authentication\Exceptions\InvalidTokenException; use OCP\Defaults; use OCP\IL10N; use OCP\IRequest; @@ -211,7 +212,7 @@ class ClientFlowLoginV2Controller extends Controller { try { $token = \OC::$server->get(\OC\Authentication\Token\IProvider::class)->getToken($password); if ($token->getLoginName() !== $user) { - throw new InvalidTokenException('login name does not match'); + throw new OcInvalidTokenException('login name does not match'); } } catch (InvalidTokenException $e) { $response = new StandaloneTemplateResponse( diff --git a/core/Controller/WipeController.php b/core/Controller/WipeController.php index 537fd7126f6..c18b74e4b96 100644 --- a/core/Controller/WipeController.php +++ b/core/Controller/WipeController.php @@ -26,11 +26,11 @@ declare(strict_types=1); */ namespace OC\Core\Controller; -use OC\Authentication\Exceptions\InvalidTokenException; use OC\Authentication\Token\RemoteWipe; use OCP\AppFramework\Controller; use OCP\AppFramework\Http; use OCP\AppFramework\Http\JSONResponse; +use OCP\Authentication\Exceptions\InvalidTokenException; use OCP\IRequest; class WipeController extends Controller { diff --git a/core/Service/LoginFlowV2Service.php b/core/Service/LoginFlowV2Service.php index 7e254672ebd..e6a2d93b77d 100644 --- a/core/Service/LoginFlowV2Service.php +++ b/core/Service/LoginFlowV2Service.php @@ -26,7 +26,6 @@ declare(strict_types=1); */ namespace OC\Core\Service; -use OC\Authentication\Exceptions\InvalidTokenException; use OC\Authentication\Exceptions\PasswordlessTokenException; use OC\Authentication\Token\IProvider; use OC\Authentication\Token\IToken; @@ -37,6 +36,7 @@ use OC\Core\Db\LoginFlowV2Mapper; use OC\Core\Exception\LoginFlowV2NotFoundException; use OCP\AppFramework\Db\DoesNotExistException; use OCP\AppFramework\Utility\ITimeFactory; +use OCP\Authentication\Exceptions\InvalidTokenException; use OCP\IConfig; use OCP\Security\ICrypto; use OCP\Security\ISecureRandom; -- cgit v1.2.3