From ebf21bed5135d310116ab9ec61b66be2a621922c Mon Sep 17 00:00:00 2001 From: Alexander Piskun Date: Tue, 1 Aug 2023 14:50:59 +0300 Subject: [PATCH 1/2] added Application Ecosystem V2 login handler Signed-off-by: Alexander Piskun --- lib/base.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/lib/base.php b/lib/base.php index ed62494ab309d..4a4c776259542 100644 --- a/lib/base.php +++ b/lib/base.php @@ -1138,6 +1138,9 @@ public static function handleLogin(OCP\IRequest $request): bool { if (OC_User::handleApacheAuth()) { return true; } + if (self::tryAppEcosystemV2Login($request)) { + return true; + } if ($userSession->tryTokenLogin($request)) { return true; } @@ -1175,6 +1178,18 @@ protected static function handleAuthHeaders(): void { } } } + + protected static function tryAppEcosystemV2Login(OCP\IRequest $request): bool { + $appManager = Server::get(OCP\App\IAppManager::class); + if (!$request->getHeader('AE-SIGNATURE')) { + return false; + } + if (!$appManager->isInstalled('app_ecosystem_v2')) { + return false; + } + $appEcosystemV2Service = Server::get(OCA\AppEcosystemV2\Service\AppEcosystemV2Service::class); + return $appEcosystemV2Service->validateExAppRequestToNC($request); + } } OC::init(); From c2a8280743d6361339fc8c6188de4063f9ef9268 Mon Sep 17 00:00:00 2001 From: Andrey Borysenko Date: Wed, 2 Aug 2023 17:40:58 +0300 Subject: [PATCH 2/2] Fix psalm ci (stub). Wrap server container with try-catch Signed-off-by: Andrey Borysenko --- build/stubs/app_ecosystem_v2.php | 15 +++++++++++++++ lib/base.php | 8 ++++++-- psalm.xml | 1 + 3 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 build/stubs/app_ecosystem_v2.php diff --git a/build/stubs/app_ecosystem_v2.php b/build/stubs/app_ecosystem_v2.php new file mode 100644 index 0000000000000..d2b07c9c61628 --- /dev/null +++ b/build/stubs/app_ecosystem_v2.php @@ -0,0 +1,15 @@ +isInstalled('app_ecosystem_v2')) { return false; } - $appEcosystemV2Service = Server::get(OCA\AppEcosystemV2\Service\AppEcosystemV2Service::class); - return $appEcosystemV2Service->validateExAppRequestToNC($request); + try { + $appEcosystemV2Service = Server::get(OCA\AppEcosystemV2\Service\AppEcosystemV2Service::class); + return $appEcosystemV2Service->validateExAppRequestToNC($request); + } catch (\Psr\Container\NotFoundExceptionInterface|\Psr\Container\ContainerExceptionInterface $e) { + return false; + } } } diff --git a/psalm.xml b/psalm.xml index 831b875d5a000..52eb9841aec43 100644 --- a/psalm.xml +++ b/psalm.xml @@ -81,6 +81,7 @@ +