Skip to content

Commit

Permalink
Merge pull request #39655 from nextcloud/appecosystem-auth
Browse files Browse the repository at this point in the history
AppEcosystem Authentification
  • Loading branch information
AndyScherzinger authored Aug 10, 2023
2 parents 51833a5 + f7b2dc8 commit a38a86e
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 @@ -1137,6 +1137,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 @@ -1174,6 +1177,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>
<LessSpecificReturnStatement errorLevel="error"/>
Expand Down

0 comments on commit a38a86e

Please sign in to comment.