Skip to content

Commit ec4768e

Browse files
committed
ILookupClient
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
1 parent 6fac431 commit ec4768e

10 files changed

Lines changed: 124 additions & 6 deletions

File tree

apps/cloud_federation_api/lib/Controller/OCMRequestController.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ public function manageOCMRequests(string $ocmPath): Response {
5858

5959
$ocmAddress = null;
6060
$params = $this->request->getParams();
61+
//
6162
foreach (['owner', 'sender', 'sharedBy'] as $field) {
6263
if (is_string($params[$field] ?? null) && $params[$field] !== '') {
6364
$ocmAddress = $params[$field];

lib/composer/composer/autoload_classmap.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -643,6 +643,7 @@
643643
'OCP\\FullTextSearch\\Service\\ISearchService' => $baseDir . '/lib/public/FullTextSearch/Service/ISearchService.php',
644644
'OCP\\GlobalScale\\IConfig' => $baseDir . '/lib/public/GlobalScale/IConfig.php',
645645
'OCP\\GlobalScale\\IGlobalScaleService' => $baseDir . '/lib/public/GlobalScale/IGlobalScaleService.php',
646+
'OCP\\GlobalScale\\ILookupClient' => $baseDir . '/lib/public/GlobalScale/ILookupClient.php',
646647
'OCP\\GroupInterface' => $baseDir . '/lib/public/GroupInterface.php',
647648
'OCP\\Group\\Backend\\ABackend' => $baseDir . '/lib/public/Group/Backend/ABackend.php',
648649
'OCP\\Group\\Backend\\IAddToGroupBackend' => $baseDir . '/lib/public/Group/Backend/IAddToGroupBackend.php',
@@ -2008,6 +2009,7 @@
20082009
'OC\\FullTextSearch\\Model\\SearchRequestSimpleQuery' => $baseDir . '/lib/private/FullTextSearch/Model/SearchRequestSimpleQuery.php',
20092010
'OC\\FullTextSearch\\Model\\SearchTemplate' => $baseDir . '/lib/private/FullTextSearch/Model/SearchTemplate.php',
20102011
'OC\\GlobalScale\\Config' => $baseDir . '/lib/private/GlobalScale/Config.php',
2012+
'OC\\GlobalScale\\DefaultLookupClient' => $baseDir . '/lib/private/GlobalScale/DefaultLookupClient.php',
20112013
'OC\\Group\\Backend' => $baseDir . '/lib/private/Group/Backend.php',
20122014
'OC\\Group\\Database' => $baseDir . '/lib/private/Group/Database.php',
20132015
'OC\\Group\\DisplayNameCache' => $baseDir . '/lib/private/Group/DisplayNameCache.php',

lib/composer/composer/autoload_static.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,32 +11,32 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2
1111
);
1212

1313
public static $prefixLengthsPsr4 = array (
14-
'O' =>
14+
'O' =>
1515
array (
1616
'OC\\Core\\' => 8,
1717
'OC\\' => 3,
1818
'OCP\\' => 4,
1919
),
20-
'N' =>
20+
'N' =>
2121
array (
2222
'NCU\\' => 4,
2323
),
2424
);
2525

2626
public static $prefixDirsPsr4 = array (
27-
'OC\\Core\\' =>
27+
'OC\\Core\\' =>
2828
array (
2929
0 => __DIR__ . '/../../..' . '/core',
3030
),
31-
'OC\\' =>
31+
'OC\\' =>
3232
array (
3333
0 => __DIR__ . '/../../..' . '/lib/private',
3434
),
35-
'OCP\\' =>
35+
'OCP\\' =>
3636
array (
3737
0 => __DIR__ . '/../../..' . '/lib/public',
3838
),
39-
'NCU\\' =>
39+
'NCU\\' =>
4040
array (
4141
0 => __DIR__ . '/../../..' . '/lib/unstable',
4242
),
@@ -684,6 +684,7 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2
684684
'OCP\\FullTextSearch\\Service\\ISearchService' => __DIR__ . '/../../..' . '/lib/public/FullTextSearch/Service/ISearchService.php',
685685
'OCP\\GlobalScale\\IConfig' => __DIR__ . '/../../..' . '/lib/public/GlobalScale/IConfig.php',
686686
'OCP\\GlobalScale\\IGlobalScaleService' => __DIR__ . '/../../..' . '/lib/public/GlobalScale/IGlobalScaleService.php',
687+
'OCP\\GlobalScale\\ILookupClient' => __DIR__ . '/../../..' . '/lib/public/GlobalScale/ILookupClient.php',
687688
'OCP\\GroupInterface' => __DIR__ . '/../../..' . '/lib/public/GroupInterface.php',
688689
'OCP\\Group\\Backend\\ABackend' => __DIR__ . '/../../..' . '/lib/public/Group/Backend/ABackend.php',
689690
'OCP\\Group\\Backend\\IAddToGroupBackend' => __DIR__ . '/../../..' . '/lib/public/Group/Backend/IAddToGroupBackend.php',
@@ -2049,6 +2050,7 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2
20492050
'OC\\FullTextSearch\\Model\\SearchRequestSimpleQuery' => __DIR__ . '/../../..' . '/lib/private/FullTextSearch/Model/SearchRequestSimpleQuery.php',
20502051
'OC\\FullTextSearch\\Model\\SearchTemplate' => __DIR__ . '/../../..' . '/lib/private/FullTextSearch/Model/SearchTemplate.php',
20512052
'OC\\GlobalScale\\Config' => __DIR__ . '/../../..' . '/lib/private/GlobalScale/Config.php',
2053+
'OC\\GlobalScale\\DefaultLookupClient' => __DIR__ . '/../../..' . '/lib/private/GlobalScale/DefaultLookupClient.php',
20522054
'OC\\Group\\Backend' => __DIR__ . '/../../..' . '/lib/private/Group/Backend.php',
20532055
'OC\\Group\\Database' => __DIR__ . '/../../..' . '/lib/private/Group/Database.php',
20542056
'OC\\Group\\DisplayNameCache' => __DIR__ . '/../../..' . '/lib/private/Group/DisplayNameCache.php',

lib/private/AppFramework/Bootstrap/RegistrationContext.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
use OCP\Files\Conversion\IConversionProvider;
3131
use OCP\Files\Template\ICustomTemplateProvider;
3232
use OCP\GlobalScale\IGlobalScaleService;
33+
use OCP\GlobalScale\ILookupClient;
3334
use OCP\Http\WellKnown\IHandler;
3435
use OCP\Mail\Provider\IProvider as IMailProvider;
3536
use OCP\Notification\INotifier;
@@ -170,6 +171,7 @@ class RegistrationContext {
170171

171172
/** @var class-string<IGlobalScaleService>|null */
172173
private ?string $globalScaleService = null;
174+
private ?string $lookupClient = null;
173175

174176
public function __construct(
175177
private LoggerInterface $logger,
@@ -502,6 +504,13 @@ public function registerGlobalScaleService(string $globalScaleServiceClass): voi
502504
$globalScaleServiceClass
503505
);
504506
}
507+
508+
#[\Override]
509+
public function registerLookupClient(string $lookupClientClass): void {
510+
$this->context->registerLookupClient(
511+
$lookupClientClass
512+
);
513+
}
505514
};
506515
}
507516

@@ -727,6 +736,13 @@ public function registerGlobalScaleService(string $class): void {
727736
$this->globalScaleService = $class;
728737
}
729738

739+
/**
740+
* @param class-string<ILookupClient> $class
741+
*/
742+
public function registerLookupClient(string $class): void {
743+
$this->lookupClient = $class;
744+
}
745+
730746
/**
731747
* @param App[] $apps
732748
*/
@@ -1119,4 +1135,11 @@ public function getConfigLexicon(string $appId): ?ILexicon {
11191135
public function getGlobalScaleService(): ?string {
11201136
return $this->globalScaleService;
11211137
}
1138+
1139+
/**
1140+
* @return ?class-string<ILookupClient>
1141+
*/
1142+
public function getLookupClient(): ?string {
1143+
return $this->lookupClient;
1144+
}
11221145
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/**
6+
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
7+
* SPDX-License-Identifier: AGPL-3.0-or-later
8+
*/
9+
namespace OC\GlobalScale;
10+
11+
use OCP\GlobalScale\ILookupClient;
12+
13+
class DefaultLookupClient implements ILookupClient {
14+
15+
public function info(): array {
16+
return [];
17+
}
18+
19+
public function search(): array {
20+
return [];
21+
}
22+
23+
public function registerUser(): bool {
24+
return true;
25+
}
26+
27+
public function unregisterUser(): bool {
28+
return true;
29+
}
30+
31+
public function updateUsers(): array {
32+
return [];
33+
}
34+
35+
public function dropUsers(): void {
36+
}
37+
}
38+

lib/private/OCM/OCMDiscoveryService.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,7 @@ public function getLocalOCMProvider(bool $fullDetails = true): IOCMProvider {
269269
*/
270270
#[\Override]
271271
public function getIncomingSignedRequest(?string $ocmAddress = null): ?IIncomingSignedRequest {
272+
//
272273
$origin = $ocmAddress !== null ? $this->getHostFromOcmAddress($ocmAddress) : null;
273274
try {
274275
$signedRequest = $this->signatureManager->getIncomingSignedRequest($this->signatoryManager, null, $origin);

lib/private/Security/Signature/SignatureManager.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,8 @@ private function getRfc9421IncomingSignedRequest(
151151
if (!($signatoryManager instanceof IJwkResolvingSignatoryManager)) {
152152
throw new IncomingRequestException('RFC 9421 inbound is not supported by ' . get_class($signatoryManager));
153153
}
154+
//
155+
154156
if ($origin === null || $origin === '') {
155157
// The keyid is opaque; the caller must supply the signer origin.
156158
throw new IncomingRequestException('RFC 9421 verification requires the sender origin');

lib/private/Server.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@
7878
use OC\Files\View;
7979
use OC\FilesMetadata\FilesMetadataManager;
8080
use OC\FullTextSearch\FullTextSearchManager;
81+
use OC\GlobalScale\DefaultLookupClient;
8182
use OC\Http\Client\ClientService;
8283
use OC\IntegrityCheck\Checker;
8384
use OC\IntegrityCheck\Helpers\EnvironmentHelper;
@@ -209,6 +210,7 @@
209210
use OCP\FilesMetadata\IFilesMetadataManager;
210211
use OCP\FullTextSearch\IFullTextSearchManager;
211212
use OCP\GlobalScale\IGlobalScaleService;
213+
use OCP\GlobalScale\ILookupClient;
212214
use OCP\Group\ISubAdmin;
213215
use OCP\Http\Client\IClientService;
214216
use OCP\IAppConfig;
@@ -1172,6 +1174,19 @@ function () use ($c) {
11721174
return $c->get($globalScaleServiceClass);
11731175
});
11741176

1177+
$this->registerService(ILookupClient::class, function (ContainerInterface $c): ILookupClient {
1178+
/** @var Coordinator $coordinator */
1179+
$coordinator = $c->get(Coordinator::class);
1180+
$registrationContext = $coordinator->getRegistrationContext();
1181+
$lookupClientClass = $registrationContext->getLookupClient();
1182+
if ($lookupClientClass === null) {
1183+
// fall back to default lookup client
1184+
$registrationContext->registerLookupClient(DefaultLookupClient::class);
1185+
$lookupClientClass = $registrationContext->getLookupClient();
1186+
}
1187+
return $c->get($lookupClientClass);
1188+
});
1189+
11751190
$this->connectDispatcher();
11761191
}
11771192

lib/public/AppFramework/Bootstrap/IRegistrationContext.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use OCP\EventDispatcher\IEventDispatcher;
1818
use OCP\Files\Template\ICustomTemplateProvider;
1919
use OCP\GlobalScale\IGlobalScaleService;
20+
use OCP\GlobalScale\ILookupClient;
2021
use OCP\IContainer;
2122
use OCP\Mail\Provider\IProvider as IMailProvider;
2223
use OCP\Notification\INotifier;
@@ -461,4 +462,13 @@ public function registerConfigLexicon(string $configLexiconClass): void;
461462
* @since 34.0.3
462463
*/
463464
public function registerGlobalScaleService(string $globalScaleServiceClass): void;
465+
466+
/**
467+
* Register an implementation of {@see ILookupClient} that will handle
468+
* communication and request to a lookup server
469+
*
470+
* @param class-string<ILookupClient> $lookupClientClass
471+
* @since 36.0.0
472+
*/
473+
public function registerLookupClient(string $lookupClientClass): void;
464474
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/**
6+
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
7+
* SPDX-License-Identifier: AGPL-3.0-or-later
8+
*/
9+
namespace OCP\GlobalScale;
10+
11+
/**
12+
* Interface needed by a client to communicate with a remote lookup server to
13+
* fulfill features provided by globalscale.
14+
*
15+
* @since 36.0.0
16+
*/
17+
interface ILookupClient {
18+
public function info(): array;
19+
public function search(): array;
20+
public function registerUser(): bool;
21+
public function unregisterUser(): bool;
22+
public function updateUsers(): array;
23+
public function dropUsers(): void;
24+
}

0 commit comments

Comments
 (0)