aboutsummaryrefslogtreecommitdiffstats
path: root/apps/settings
diff options
context:
space:
mode:
authorCôme Chilliet <91878298+come-nc@users.noreply.github.com>2024-01-11 18:51:43 +0100
committerGitHub <noreply@github.com>2024-01-11 18:51:43 +0100
commitf7897329227772bf4cc36c6b1001a4861b4c3b7e (patch)
tree2beeeabed72772b5b34513b8486de7befb5aaf21 /apps/settings
parent07749e6a295e3d9fda638cb04114fceb25ca56fe (diff)
parenta526a382bf858ed01a5f62d79a760333d8885595 (diff)
downloadnextcloud-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/settings')
-rw-r--r--apps/settings/lib/Controller/AuthSettingsController.php14
-rw-r--r--apps/settings/lib/Settings/Personal/Security/Authtokens.php2
2 files changed, 9 insertions, 7 deletions
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;