Skip to content

Commit 4e42b99

Browse files
ArtificialOwlbackportbot[bot]
authored andcommitted
fix(ocm): fully disable signed request on config
Signed-off-by: Maxence Lange <[email protected]>
1 parent 38a9487 commit 4e42b99

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
@@ -96,14 +96,16 @@ public function __construct(
9696
#[NoCSRFRequired]
9797
#[BruteForceProtection(action: 'receiveFederatedShare')]
9898
public function addShare($shareWith, $name, $description, $providerId, $owner, $ownerDisplayName, $sharedBy, $sharedByDisplayName, $protocol, $shareType, $resourceType) {
99-
try {
100-
// if request is signed and well signed, no exception are thrown
101-
// if request is not signed and host is known for not supporting signed request, no exception are thrown
102-
$signedRequest = $this->getSignedRequest();
103-
$this->confirmSignedOrigin($signedRequest, 'owner', $owner);
104-
} catch (IncomingRequestException $e) {
105-
$this->logger->warning('incoming request exception', ['exception' => $e]);
106-
return new JSONResponse(['message' => $e->getMessage(), 'validationErrors' => []], Http::STATUS_BAD_REQUEST);
99+
if (!$this->appConfig->getValueBool('core', OCMSignatoryManager::APPCONFIG_SIGN_DISABLED, lazy: true)) {
100+
try {
101+
// if request is signed and well signed, no exception are thrown
102+
// if request is not signed and host is known for not supporting signed request, no exception are thrown
103+
$signedRequest = $this->getSignedRequest();
104+
$this->confirmSignedOrigin($signedRequest, 'owner', $owner);
105+
} catch (IncomingRequestException $e) {
106+
$this->logger->warning('incoming request exception', ['exception' => $e]);
107+
return new JSONResponse(['message' => $e->getMessage(), 'validationErrors' => []], Http::STATUS_BAD_REQUEST);
108+
}
107109
}
108110

109111
// check if all required parameters are set
@@ -247,14 +249,16 @@ public function receiveNotification($notificationType, $resourceType, $providerI
247249
);
248250
}
249251

250-
try {
251-
// if request is signed and well signed, no exception are thrown
252-
// if request is not signed and host is known for not supporting signed request, no exception are thrown
253-
$signedRequest = $this->getSignedRequest();
254-
$this->confirmNotificationIdentity($signedRequest, $resourceType, $notification);
255-
} catch (IncomingRequestException $e) {
256-
$this->logger->warning('incoming request exception', ['exception' => $e]);
257-
return new JSONResponse(['message' => $e->getMessage(), 'validationErrors' => []], Http::STATUS_BAD_REQUEST);
252+
if (!$this->appConfig->getValueBool('core', OCMSignatoryManager::APPCONFIG_SIGN_DISABLED, lazy: true)) {
253+
try {
254+
// if request is signed and well signed, no exception are thrown
255+
// if request is not signed and host is known for not supporting signed request, no exception are thrown
256+
$signedRequest = $this->getSignedRequest();
257+
$this->confirmNotificationIdentity($signedRequest, $resourceType, $notification);
258+
} catch (IncomingRequestException $e) {
259+
$this->logger->warning('incoming request exception', ['exception' => $e]);
260+
return new JSONResponse(['message' => $e->getMessage(), 'validationErrors' => []], Http::STATUS_BAD_REQUEST);
261+
}
258262
}
259263

260264
try {

0 commit comments

Comments
 (0)