Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions config/config.sample.php
Original file line number Diff line number Diff line change
Expand Up @@ -2276,6 +2276,24 @@
*/
'sharing.federation.allowSelfSignedCertificates' => false,

/**
* Override the ``apiVersion`` advertised in the local OCM discovery document.
* Setting this to a non-empty string also removes the non-standard ``version``
* field. Leave empty for compatibility with older Nextcloud servers.
*
* Defaults to ``''`` (empty string)
*/
'sharing.federation.ocm.apiVersion' => '',

/**
* Remove the non-standard ``publicKey`` field from the local OCM discovery
* document. Enable this only when all federated peers support RFC 9421 HTTP
* signatures, for example when all peers run Nextcloud 35 or higher.
*
* Defaults to ``false``
*/
'sharing.federation.ocm.removePublicKey' => false,

/**
* Hashing
*/
Expand Down
27 changes: 27 additions & 0 deletions lib/private/OCM/Model/OCMProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
*/
class OCMProvider implements IOCMProvider {
private bool $enabled = false;
private bool $removePublicKey = false;
private bool $removeVersion = false;
private string $apiVersion = '';
private string $inviteAcceptDialog = '';
private array $capabilities = [];
Expand Down Expand Up @@ -350,6 +352,22 @@ private function looksValid(): bool {
return ($this->getApiVersion() !== '' && $this->getEndPoint() !== '');
}

/**
* @since 35.0.0
*/
#[\Override]
public function removePublicKey(): void {
$this->removePublicKey = true;
}

/**
* @since 35.0.0
*/
#[\Override]
public function removeVersion(): void {
$this->removeVersion = true;
}

/**
* @since 28.0.0
*/
Expand All @@ -370,6 +388,15 @@ public function jsonSerialize(): array {
'resourceTypes' => $resourceTypes
];

if ($this->removeVersion) {
$response['apiVersion'] = $this->getApiVersion();
unset($response['version']);
}

if ($this->removePublicKey) {
unset($response['publicKey']);
}

if ($this->capabilities !== []) {
$response['capabilities'] = $this->capabilities;
}
Expand Down
9 changes: 9 additions & 0 deletions lib/private/OCM/OCMDiscoveryService.php
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,15 @@ public function getLocalOCMProvider(bool $fullDetails = true): IOCMProvider {
$event = new ResourceTypeRegisterEvent($provider);
$this->eventDispatcher->dispatchTyped($event);

$apiVersion = $this->config->getSystemValueString('sharing.federation.ocm.apiVersion');
if ($apiVersion !== '') {
$provider->setApiVersion($apiVersion);
$provider->removeVersion();
}
if ($this->config->getSystemValueBool('sharing.federation.ocm.removePublicKey')) {
$provider->removePublicKey();
}

$this->localProvider = $provider;
return $provider;
}
Expand Down
29 changes: 29 additions & 0 deletions lib/public/OCM/Events/LocalOCMDiscoveryEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,33 @@ public function registerResourceType(string $name, array $shareTypes, array $pro
public function getProvider(): IOCMProvider {
return $this->provider;
}

/**
* Remove the non-standard publicKey field from OCM discovery
*
* @since 35.0.0
*/
public function removePublicKey(): void {
$this->provider->removePublicKey();
}

/**
* Remove the non-standard version field from OCM discovery
*
* @since 35.0.0
*/
public function removeVersion(): void {
$this->provider->removeVersion();
}

/**
* Set the apiVersion
*
* @param string $version
*
* @since 35.0.0
*/
public function setApiVersion(string $version): void {
$this->provider->setApiVersion($version);
}
}
18 changes: 16 additions & 2 deletions lib/public/OCM/IOCMProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,20 @@ public function setApiVersion(string $apiVersion): static;
*/
public function getApiVersion(): string;

/**
* Remove the non-standard publicKey field from OCM discovery
*
* @since 35.0.0
*/
public function removePublicKey(): void;

/**
* Remove the non-standard version field from OCM discovery
*
* @since 35.0.0
*/
public function removeVersion(): void;

/**
* configure endpoint
*
Expand Down Expand Up @@ -240,7 +254,7 @@ public function import(array $data): static;
/**
* @return array{
* enabled: bool,
* apiVersion: '1.0-proposal1',
* apiVersion: string,
* endPoint: string,
* publicKey?: array{
* keyId: string,
Expand All @@ -251,7 +265,7 @@ public function import(array $data): static;
* shareTypes: list<string>,
* protocols: array<string, string>
* }>,
* version: string,
* version?: string,
* jwksUri?: string
* }
* @since 28.0.0
Expand Down
Loading