Skip to content

Commit 26ce4e5

Browse files
committed
fix(federatedfilesharing): POSTs to token endpoint MUST be signed
Signed-off-by: Enrique Pérez Arnaud <enrique@cazalla.net>
1 parent 0ed2cac commit 26ce4e5

File tree

2 files changed

+30
-34
lines changed

2 files changed

+30
-34
lines changed

apps/federatedfilesharing/lib/OCM/CloudFederationProviderFiles.php

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -757,23 +757,21 @@ private function exchangeToken(string $remote, #[SensitiveParameter] string $sha
757757
'connect_timeout' => 10,
758758
];
759759

760-
// Try signing the request
761-
if (!$this->appConfig->getValueBool('core', OCMSignatoryManager::APPCONFIG_SIGN_DISABLED, lazy: true)) {
762-
try {
763-
$options = $this->signatureManager->signOutgoingRequestIClientPayload(
764-
$this->signatoryManager,
765-
$options,
766-
'post',
767-
$tokenEndpoint
768-
);
769-
$this->logger->debug('Token request signed successfully', ['remote' => $remote]);
770-
} catch (\Exception $e) {
771-
$this->logger->warning('Failed to sign token request, continuing without signature', [
772-
'remote' => $remote,
773-
'exception' => $e,
774-
'endpoint' => $tokenEndpoint,
775-
]);
776-
}
760+
try {
761+
$options = $this->signatureManager->signOutgoingRequestIClientPayload(
762+
$this->signatoryManager,
763+
$options,
764+
'post',
765+
$tokenEndpoint
766+
);
767+
$this->logger->debug('Token request signed successfully', ['remote' => $remote]);
768+
} catch (\Exception $e) {
769+
$this->logger->error('Failed to sign token request', [
770+
'remote' => $remote,
771+
'exception' => $e,
772+
'endpoint' => $tokenEndpoint,
773+
]);
774+
return null;
777775
}
778776

779777
$response = $client->post($tokenEndpoint, $options);

lib/private/Files/Storage/DAV.php

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -281,23 +281,21 @@ protected function exchangeRefreshToken(): string {
281281
'connect_timeout' => 10,
282282
];
283283

284-
// Try signing the request
285-
if (!$this->appConfig->getValueBool('core', OCMSignatoryManager::APPCONFIG_SIGN_DISABLED, lazy: true)) {
286-
try {
287-
$options = $this->signatureManager->signOutgoingRequestIClientPayload(
288-
$this->signatoryManager,
289-
$options,
290-
'post',
291-
$tokenEndpoint
292-
);
293-
$this->logger->debug('Token request signed successfully', ['app' => 'dav']);
294-
} catch (\Exception $e) {
295-
$this->logger->warning('Failed to sign token request, continuing without signature', [
296-
'app' => 'dav',
297-
'exception' => $e,
298-
'endpoint' => $tokenEndpoint,
299-
]);
300-
}
284+
try {
285+
$options = $this->signatureManager->signOutgoingRequestIClientPayload(
286+
$this->signatoryManager,
287+
$options,
288+
'post',
289+
$tokenEndpoint
290+
);
291+
$this->logger->debug('Token request signed successfully', ['app' => 'dav']);
292+
} catch (\Exception $e) {
293+
$this->logger->error('Failed to sign token request', [
294+
'app' => 'dav',
295+
'exception' => $e,
296+
'endpoint' => $tokenEndpoint,
297+
]);
298+
throw new StorageNotAvailableException('Could not sign token request: ' . $e->getMessage());
301299
}
302300

303301
$response = $client->post($tokenEndpoint, $options);

0 commit comments

Comments
 (0)