diff options
author | Côme Chilliet <91878298+come-nc@users.noreply.github.com> | 2024-01-11 18:51:43 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-11 18:51:43 +0100 |
commit | f7897329227772bf4cc36c6b1001a4861b4c3b7e (patch) | |
tree | 2beeeabed72772b5b34513b8486de7befb5aaf21 /apps | |
parent | 07749e6a295e3d9fda638cb04114fceb25ca56fe (diff) | |
parent | a526a382bf858ed01a5f62d79a760333d8885595 (diff) | |
download | nextcloud-server-f7897329227772bf4cc36c6b1001a4861b4c3b7e.tar.gz nextcloud-server-f7897329227772bf4cc36c6b1001a4861b4c3b7e.zip |
Merge pull request #42640 from nextcloud/fix/fix-authentication-exceptions-2
Always catch OCP versions of authentication exceptions
Diffstat (limited to 'apps')
4 files changed, 12 insertions, 10 deletions
diff --git a/apps/oauth2/lib/Controller/OauthApiController.php b/apps/oauth2/lib/Controller/OauthApiController.php index dfb952a0951..46b68b1d585 100644 --- a/apps/oauth2/lib/Controller/OauthApiController.php +++ b/apps/oauth2/lib/Controller/OauthApiController.php @@ -28,8 +28,6 @@ declare(strict_types=1); */ namespace OCA\OAuth2\Controller; -use OC\Authentication\Exceptions\ExpiredTokenException; -use OC\Authentication\Exceptions\InvalidTokenException; use OC\Authentication\Token\IProvider as TokenProvider; use OCA\OAuth2\Db\AccessTokenMapper; use OCA\OAuth2\Db\ClientMapper; @@ -39,6 +37,8 @@ use OCP\AppFramework\Controller; use OCP\AppFramework\Http; use OCP\AppFramework\Http\JSONResponse; use OCP\AppFramework\Utility\ITimeFactory; +use OCP\Authentication\Exceptions\ExpiredTokenException; +use OCP\Authentication\Exceptions\InvalidTokenException; use OCP\DB\Exception; use OCP\IRequest; use OCP\Security\Bruteforce\IThrottler; diff --git a/apps/oauth2/lib/Migration/SetTokenExpiration.php b/apps/oauth2/lib/Migration/SetTokenExpiration.php index 696d3b7f04a..5a5c5ff4781 100644 --- a/apps/oauth2/lib/Migration/SetTokenExpiration.php +++ b/apps/oauth2/lib/Migration/SetTokenExpiration.php @@ -26,10 +26,10 @@ declare(strict_types=1); */ namespace OCA\OAuth2\Migration; -use OC\Authentication\Exceptions\InvalidTokenException; use OC\Authentication\Token\IProvider as TokenProvider; use OCA\OAuth2\Db\AccessToken; use OCP\AppFramework\Utility\ITimeFactory; +use OCP\Authentication\Exceptions\InvalidTokenException; use OCP\IDBConnection; use OCP\Migration\IOutput; use OCP\Migration\IRepairStep; diff --git a/apps/settings/lib/Controller/AuthSettingsController.php b/apps/settings/lib/Controller/AuthSettingsController.php index c0dc8cbac85..8a01c7c2468 100644 --- a/apps/settings/lib/Controller/AuthSettingsController.php +++ b/apps/settings/lib/Controller/AuthSettingsController.php @@ -32,19 +32,20 @@ namespace OCA\Settings\Controller; use BadMethodCallException; -use OC\Authentication\Exceptions\ExpiredTokenException; -use OC\Authentication\Exceptions\InvalidTokenException; +use OC\Authentication\Exceptions\InvalidTokenException as OcInvalidTokenException; use OC\Authentication\Exceptions\PasswordlessTokenException; -use OC\Authentication\Exceptions\WipeTokenException; use OC\Authentication\Token\INamedToken; use OC\Authentication\Token\IProvider; -use OC\Authentication\Token\IToken; use OC\Authentication\Token\RemoteWipe; use OCA\Settings\Activity\Provider; use OCP\Activity\IManager; use OCP\AppFramework\Controller; use OCP\AppFramework\Http; use OCP\AppFramework\Http\JSONResponse; +use OCP\Authentication\Exceptions\ExpiredTokenException; +use OCP\Authentication\Exceptions\InvalidTokenException; +use OCP\Authentication\Exceptions\WipeTokenException; +use OCP\Authentication\Token\IToken; use OCP\IRequest; use OCP\ISession; use OCP\IUserSession; @@ -292,7 +293,8 @@ class AuthSettingsController extends Controller { $token = $e->getToken(); } if ($token->getUID() !== $this->uid) { - throw new InvalidTokenException('This token does not belong to you!'); + /** @psalm-suppress DeprecatedClass We have to throw the OC version so both OC and OCP catches catch it */ + throw new OcInvalidTokenException('This token does not belong to you!'); } return $token; } @@ -305,7 +307,7 @@ class AuthSettingsController extends Controller { * @param int $id * @return JSONResponse * @throws InvalidTokenException - * @throws \OC\Authentication\Exceptions\ExpiredTokenException + * @throws ExpiredTokenException */ public function wipe(int $id): JSONResponse { if ($this->checkAppToken()) { diff --git a/apps/settings/lib/Settings/Personal/Security/Authtokens.php b/apps/settings/lib/Settings/Personal/Security/Authtokens.php index e713344ce88..9a7405fb7a2 100644 --- a/apps/settings/lib/Settings/Personal/Security/Authtokens.php +++ b/apps/settings/lib/Settings/Personal/Security/Authtokens.php @@ -25,12 +25,12 @@ declare(strict_types=1); */ namespace OCA\Settings\Settings\Personal\Security; -use OC\Authentication\Exceptions\InvalidTokenException; use OC\Authentication\Token\INamedToken; use OC\Authentication\Token\IProvider as IAuthTokenProvider; use OC\Authentication\Token\IToken; use OCP\AppFramework\Http\TemplateResponse; use OCP\AppFramework\Services\IInitialState; +use OCP\Authentication\Exceptions\InvalidTokenException; use OCP\ISession; use OCP\IUserSession; use OCP\Session\Exceptions\SessionNotAvailableException; |