Skip to content

Commit

Permalink
Merge pull request #39799 from nextcloud/appecosystem-auth-stable27
Browse files Browse the repository at this point in the history
  • Loading branch information
skjnldsv authored Aug 11, 2023
2 parents 9df163c + c2a8280 commit c239d69
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
15 changes: 15 additions & 0 deletions build/stubs/app_ecosystem_v2.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

namespace OCA\AppEcosystemV2\Service;

use OCP\IRequest;

class AppEcosystemV2Service {
/**
* @param IRequest $request
* @param bool $isDav
*
* @return bool
*/
public function validateExAppRequestToNC(IRequest $request, bool $isDav = false): bool {}
}
19 changes: 19 additions & 0 deletions lib/base.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -1175,6 +1178,22 @@ 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;
}
try {
$appEcosystemV2Service = Server::get(OCA\AppEcosystemV2\Service\AppEcosystemV2Service::class);
return $appEcosystemV2Service->validateExAppRequestToNC($request);
} catch (\Psr\Container\NotFoundExceptionInterface|\Psr\Container\ContainerExceptionInterface $e) {
return false;
}
}
}

OC::init();
1 change: 1 addition & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
<file name="build/stubs/zip.php"/>
<file name="build/stubs/psr_container.php"/>
<file name="3rdparty/sabre/uri/lib/functions.php" />
<file name="build/stubs/app_ecosystem_v2.php" />
</stubs>
<issueHandlers>
<UndefinedClass>
Expand Down

0 comments on commit c239d69

Please sign in to comment.