Skip to content

Commit a4907a6

Browse files
Merge pull request #57184 from nextcloud/backport/57156/stable32
[stable32] fix(ocm): fully disable signed request on config
2 parents 154d266 + 698f47d commit a4907a6

File tree

1 file changed

+20
-16
lines changed

1 file changed

+20
-16
lines changed

apps/cloud_federation_api/lib/Controller/RequestHandlerController.php

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -118,14 +118,16 @@ public function addShare($shareWith, $name, $description, $providerId, $owner, $
118118
];
119119
}
120120

121-
try {
122-
// if request is signed and well signed, no exception are thrown
123-
// if request is not signed and host is known for not supporting signed request, no exception are thrown
124-
$signedRequest = $this->getSignedRequest();
125-
$this->confirmSignedOrigin($signedRequest, 'owner', $owner);
126-
} catch (IncomingRequestException $e) {
127-
$this->logger->warning('incoming request exception', ['exception' => $e]);
128-
return new JSONResponse(['message' => $e->getMessage(), 'validationErrors' => []], Http::STATUS_BAD_REQUEST);
121+
if (!$this->appConfig->getValueBool('core', OCMSignatoryManager::APPCONFIG_SIGN_DISABLED, lazy: true)) {
122+
try {
123+
// if request is signed and well signed, no exceptions are thrown
124+
// if request is not signed and host is known for not supporting signed request, no exceptions are thrown
125+
$signedRequest = $this->getSignedRequest();
126+
$this->confirmSignedOrigin($signedRequest, 'owner', $owner);
127+
} catch (IncomingRequestException $e) {
128+
$this->logger->warning('incoming request exception', ['exception' => $e]);
129+
return new JSONResponse(['message' => $e->getMessage(), 'validationErrors' => []], Http::STATUS_BAD_REQUEST);
130+
}
129131
}
130132

131133
// check if all required parameters are set
@@ -366,14 +368,16 @@ public function receiveNotification($notificationType, $resourceType, $providerI
366368
);
367369
}
368370

369-
try {
370-
// if request is signed and well signed, no exception are thrown
371-
// if request is not signed and host is known for not supporting signed request, no exception are thrown
372-
$signedRequest = $this->getSignedRequest();
373-
$this->confirmNotificationIdentity($signedRequest, $resourceType, $notification);
374-
} catch (IncomingRequestException $e) {
375-
$this->logger->warning('incoming request exception', ['exception' => $e]);
376-
return new JSONResponse(['message' => $e->getMessage(), 'validationErrors' => []], Http::STATUS_BAD_REQUEST);
371+
if (!$this->appConfig->getValueBool('core', OCMSignatoryManager::APPCONFIG_SIGN_DISABLED, lazy: true)) {
372+
try {
373+
// if request is signed and well signed, no exception are thrown
374+
// if request is not signed and host is known for not supporting signed request, no exception are thrown
375+
$signedRequest = $this->getSignedRequest();
376+
$this->confirmNotificationIdentity($signedRequest, $resourceType, $notification);
377+
} catch (IncomingRequestException $e) {
378+
$this->logger->warning('incoming request exception', ['exception' => $e]);
379+
return new JSONResponse(['message' => $e->getMessage(), 'validationErrors' => []], Http::STATUS_BAD_REQUEST);
380+
}
377381
}
378382

379383
try {

0 commit comments

Comments
 (0)