Skip to content

Commit af0c0f2

Browse files
authored
Merge branch 'master' into fix/cors-bearer-token-support
2 parents 034d436 + e91840a commit af0c0f2

File tree

220 files changed

+2093
-2472
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

220 files changed

+2093
-2472
lines changed

3rdparty

Submodule 3rdparty updated 44 files

apps/cloud_federation_api/lib/Controller/RequestHandlerController.php

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -106,14 +106,16 @@ public function __construct(
106106
#[NoCSRFRequired]
107107
#[BruteForceProtection(action: 'receiveFederatedShare')]
108108
public function addShare($shareWith, $name, $description, $providerId, $owner, $ownerDisplayName, $sharedBy, $sharedByDisplayName, $protocol, $shareType, $resourceType) {
109-
try {
110-
// if request is signed and well signed, no exception are thrown
111-
// if request is not signed and host is known for not supporting signed request, no exception are thrown
112-
$signedRequest = $this->getSignedRequest();
113-
$this->confirmSignedOrigin($signedRequest, 'owner', $owner);
114-
} catch (IncomingRequestException $e) {
115-
$this->logger->warning('incoming request exception', ['exception' => $e]);
116-
return new JSONResponse(['message' => $e->getMessage(), 'validationErrors' => []], Http::STATUS_BAD_REQUEST);
109+
if (!$this->appConfig->getValueBool('core', OCMSignatoryManager::APPCONFIG_SIGN_DISABLED, lazy: true)) {
110+
try {
111+
// if request is signed and well signed, no exception are thrown
112+
// if request is not signed and host is known for not supporting signed request, no exception are thrown
113+
$signedRequest = $this->getSignedRequest();
114+
$this->confirmSignedOrigin($signedRequest, 'owner', $owner);
115+
} catch (IncomingRequestException $e) {
116+
$this->logger->warning('incoming request exception', ['exception' => $e]);
117+
return new JSONResponse(['message' => $e->getMessage(), 'validationErrors' => []], Http::STATUS_BAD_REQUEST);
118+
}
117119
}
118120

119121
// check if all required parameters are set
@@ -354,14 +356,16 @@ public function receiveNotification($notificationType, $resourceType, $providerI
354356
);
355357
}
356358

357-
try {
358-
// if request is signed and well signed, no exception are thrown
359-
// if request is not signed and host is known for not supporting signed request, no exception are thrown
360-
$signedRequest = $this->getSignedRequest();
361-
$this->confirmNotificationIdentity($signedRequest, $resourceType, $notification);
362-
} catch (IncomingRequestException $e) {
363-
$this->logger->warning('incoming request exception', ['exception' => $e]);
364-
return new JSONResponse(['message' => $e->getMessage(), 'validationErrors' => []], Http::STATUS_BAD_REQUEST);
359+
if (!$this->appConfig->getValueBool('core', OCMSignatoryManager::APPCONFIG_SIGN_DISABLED, lazy: true)) {
360+
try {
361+
// if request is signed and well signed, no exception are thrown
362+
// if request is not signed and host is known for not supporting signed request, no exception are thrown
363+
$signedRequest = $this->getSignedRequest();
364+
$this->confirmNotificationIdentity($signedRequest, $resourceType, $notification);
365+
} catch (IncomingRequestException $e) {
366+
$this->logger->warning('incoming request exception', ['exception' => $e]);
367+
return new JSONResponse(['message' => $e->getMessage(), 'validationErrors' => []], Http::STATUS_BAD_REQUEST);
368+
}
365369
}
366370

367371
try {
@@ -500,7 +504,6 @@ private function confirmSignedOrigin(?IIncomingSignedRequest $signedRequest, str
500504
*
501505
* @param IIncomingSignedRequest|null $signedRequest
502506
* @param string $resourceType
503-
* @param string $sharedSecret
504507
*
505508
* @throws IncomingRequestException
506509
* @throws BadRequestException
@@ -524,7 +527,7 @@ private function confirmNotificationIdentity(
524527
return;
525528
}
526529
} catch (\Exception $e) {
527-
throw new IncomingRequestException($e->getMessage());
530+
throw new IncomingRequestException($e->getMessage(), previous: $e);
528531
}
529532

530533
$this->confirmNotificationEntry($signedRequest, $identity);

apps/dav/l10n/de.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ OC.L10N.register(
252252
"Completed on %s" : "Erledigt am %s",
253253
"Due on %s by %s" : "Fällig am %s von %s",
254254
"Due on %s" : "Fällig am %s",
255-
"Welcome to Nextcloud Calendar!\n\nThis is a sample event - explore the flexibility of planning with Nextcloud Calendar by making any edits you want!\n\nWith Nextcloud Calendar, you can:\n- Create, edit, and manage events effortlessly.\n- Create multiple calendars and share them with teammates, friends, or family.\n- Check availability and display your busy times to others.\n- Seamlessly integrate with apps and devices via CalDAV.\n- Customize your experience: schedule recurring events, adjust notifications and other settings." : "Willkommen bei Nextcloud Calendar!\n\nDies ist ein Beispielereignis – entdecke die Flexibilität der Planung mit Nextcloud Calendar und nimm beliebige Änderungen vor!\n\nMit Nextcloud Calendar kannst du:\n– Ereignisse mühelos erstellen, bearbeiten und verwalten.\n– Mehrere Kalender erstellen und mit Teamkollegen, Freunden oder der Familie teilen.\n– Verfügbarkeit prüfen und Ihre Termine anderen anzeigen.\n– Nahtlose Integration mit Apps und Geräten über CalDAV.\n– Individuelle Gestaltung: Plane wiederkehrende Ereignisse, passe Benachrichtigungen und andere Einstellungen an.",
255+
"Welcome to Nextcloud Calendar!\n\nThis is a sample event - explore the flexibility of planning with Nextcloud Calendar by making any edits you want!\n\nWith Nextcloud Calendar, you can:\n- Create, edit, and manage events effortlessly.\n- Create multiple calendars and share them with teammates, friends, or family.\n- Check availability and display your busy times to others.\n- Seamlessly integrate with apps and devices via CalDAV.\n- Customize your experience: schedule recurring events, adjust notifications and other settings." : "Willkommen bei Nextcloud Calendar!\n\nDies ist ein Beispielereignis – entdecke die Flexibilität der Planung mit Nextcloud Calendar und nimm beliebige Änderungen vor!\n\nMit Nextcloud Calendar kannst du:\n– Ereignisse mühelos erstellen, bearbeiten und verwalten.\n– Mehrere Kalender erstellen und mit Teamkollegen, Freunden oder der Familie teilen.\n– Verfügbarkeit prüfen und deine Termine anderen anzeigen.\n– Nahtlose Integration mit Apps und Geräten über CalDAV.\n– Individuelle Gestaltung: Plane wiederkehrende Ereignisse, passe Benachrichtigungen und andere Einstellungen an.",
256256
"Example event - open me!" : "Beispielereignis – öffne mich!",
257257
"System Address Book" : "Systemadressbuch",
258258
"The system address book contains contact information for all users in your instance." : "Das Systemadressbuch enthält Kontaktinformationen für alle Benutzer in dieser Instanz.",

apps/dav/l10n/de.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@
250250
"Completed on %s" : "Erledigt am %s",
251251
"Due on %s by %s" : "Fällig am %s von %s",
252252
"Due on %s" : "Fällig am %s",
253-
"Welcome to Nextcloud Calendar!\n\nThis is a sample event - explore the flexibility of planning with Nextcloud Calendar by making any edits you want!\n\nWith Nextcloud Calendar, you can:\n- Create, edit, and manage events effortlessly.\n- Create multiple calendars and share them with teammates, friends, or family.\n- Check availability and display your busy times to others.\n- Seamlessly integrate with apps and devices via CalDAV.\n- Customize your experience: schedule recurring events, adjust notifications and other settings." : "Willkommen bei Nextcloud Calendar!\n\nDies ist ein Beispielereignis – entdecke die Flexibilität der Planung mit Nextcloud Calendar und nimm beliebige Änderungen vor!\n\nMit Nextcloud Calendar kannst du:\n– Ereignisse mühelos erstellen, bearbeiten und verwalten.\n– Mehrere Kalender erstellen und mit Teamkollegen, Freunden oder der Familie teilen.\n– Verfügbarkeit prüfen und Ihre Termine anderen anzeigen.\n– Nahtlose Integration mit Apps und Geräten über CalDAV.\n– Individuelle Gestaltung: Plane wiederkehrende Ereignisse, passe Benachrichtigungen und andere Einstellungen an.",
253+
"Welcome to Nextcloud Calendar!\n\nThis is a sample event - explore the flexibility of planning with Nextcloud Calendar by making any edits you want!\n\nWith Nextcloud Calendar, you can:\n- Create, edit, and manage events effortlessly.\n- Create multiple calendars and share them with teammates, friends, or family.\n- Check availability and display your busy times to others.\n- Seamlessly integrate with apps and devices via CalDAV.\n- Customize your experience: schedule recurring events, adjust notifications and other settings." : "Willkommen bei Nextcloud Calendar!\n\nDies ist ein Beispielereignis – entdecke die Flexibilität der Planung mit Nextcloud Calendar und nimm beliebige Änderungen vor!\n\nMit Nextcloud Calendar kannst du:\n– Ereignisse mühelos erstellen, bearbeiten und verwalten.\n– Mehrere Kalender erstellen und mit Teamkollegen, Freunden oder der Familie teilen.\n– Verfügbarkeit prüfen und deine Termine anderen anzeigen.\n– Nahtlose Integration mit Apps und Geräten über CalDAV.\n– Individuelle Gestaltung: Plane wiederkehrende Ereignisse, passe Benachrichtigungen und andere Einstellungen an.",
254254
"Example event - open me!" : "Beispielereignis – öffne mich!",
255255
"System Address Book" : "Systemadressbuch",
256256
"The system address book contains contact information for all users in your instance." : "Das Systemadressbuch enthält Kontaktinformationen für alle Benutzer in dieser Instanz.",

apps/federatedfilesharing/lib/Controller/RequestHandlerController.php

Lines changed: 25 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@
77
*/
88
namespace OCA\FederatedFileSharing\Controller;
99

10-
use OCA\FederatedFileSharing\AddressHandler;
1110
use OCA\FederatedFileSharing\FederatedShareProvider;
12-
use OCA\FederatedFileSharing\Notifications;
1311
use OCP\App\IAppManager;
1412
use OCP\AppFramework\Http;
1513
use OCP\AppFramework\Http\Attribute\NoCSRFRequired;
@@ -29,7 +27,6 @@
2927
use OCP\HintException;
3028
use OCP\IDBConnection;
3129
use OCP\IRequest;
32-
use OCP\IUserManager;
3330
use OCP\Log\Audit\CriticalActionPerformedEvent;
3431
use OCP\Server;
3532
use OCP\Share;
@@ -44,10 +41,6 @@ public function __construct(
4441
IRequest $request,
4542
private FederatedShareProvider $federatedShareProvider,
4643
private IDBConnection $connection,
47-
private Share\IManager $shareManager,
48-
private Notifications $notifications,
49-
private AddressHandler $addressHandler,
50-
private IUserManager $userManager,
5144
private ICloudIdManager $cloudIdManager,
5245
private LoggerInterface $logger,
5346
private ICloudFederationFactory $cloudFederationFactory,
@@ -66,10 +59,10 @@ public function __construct(
6659
* @param string|null $owner Display name of the receiver
6760
* @param string|null $sharedBy Display name of the sender
6861
* @param string|null $shareWith ID of the user that receives the share
69-
* @param int|null $remoteId ID of the remote
62+
* @param string|null $remoteId ID of the remote
7063
* @param string|null $sharedByFederatedId Federated ID of the sender
7164
* @param string|null $ownerFederatedId Federated ID of the receiver
72-
* @return Http\DataResponse<Http::STATUS_OK, list<empty>, array{}>
65+
* @return DataResponse<Http::STATUS_OK, list<empty>, array{}>
7366
* @throws OCSException
7467
*
7568
* 200: Share created successfully
@@ -83,10 +76,10 @@ public function createShare(
8376
?string $owner = null,
8477
?string $sharedBy = null,
8578
?string $shareWith = null,
86-
?int $remoteId = null,
79+
?string $remoteId = null,
8780
?string $sharedByFederatedId = null,
8881
?string $ownerFederatedId = null,
89-
) {
82+
): DataResponse {
9083
if ($ownerFederatedId === null) {
9184
$ownerFederatedId = $this->cloudIdManager->getCloudId($owner, $this->cleanupRemote($remote))->getId();
9285
}
@@ -132,19 +125,19 @@ public function createShare(
132125
/**
133126
* create re-share on behalf of another user
134127
*
135-
* @param int $id ID of the share
128+
* @param string $id ID of the share
136129
* @param string|null $token Shared secret between servers
137130
* @param string|null $shareWith ID of the user that receives the share
138131
* @param int|null $remoteId ID of the remote
139-
* @return Http\DataResponse<Http::STATUS_OK, array{token: string, remoteId: string}, array{}>
132+
* @return DataResponse<Http::STATUS_OK, array{token: string, remoteId: string}, array{}>
140133
* @throws OCSBadRequestException Re-sharing is not possible
141134
* @throws OCSException
142135
*
143136
* 200: Remote share returned
144137
*/
145138
#[NoCSRFRequired]
146139
#[PublicPage]
147-
public function reShare(int $id, ?string $token = null, ?string $shareWith = null, ?int $remoteId = 0) {
140+
public function reShare(string $id, ?string $token = null, ?string $shareWith = null, ?int $remoteId = 0): DataResponse {
148141
if ($token === null
149142
|| $shareWith === null
150143
|| $remoteId === null
@@ -181,9 +174,9 @@ public function reShare(int $id, ?string $token = null, ?string $shareWith = nul
181174
/**
182175
* accept server-to-server share
183176
*
184-
* @param int $id ID of the remote share
177+
* @param string $id ID of the remote share
185178
* @param string|null $token Shared secret between servers
186-
* @return Http\DataResponse<Http::STATUS_OK, list<empty>, array{}>
179+
* @return DataResponse<Http::STATUS_OK, list<empty>, array{}>
187180
* @throws OCSException
188181
* @throws ShareNotFound
189182
* @throws HintException
@@ -192,7 +185,7 @@ public function reShare(int $id, ?string $token = null, ?string $shareWith = nul
192185
*/
193186
#[NoCSRFRequired]
194187
#[PublicPage]
195-
public function acceptShare(int $id, ?string $token = null) {
188+
public function acceptShare(string $id, ?string $token = null): DataResponse {
196189
$notification = [
197190
'sharedSecret' => $token,
198191
'message' => 'Recipient accept the share'
@@ -216,16 +209,16 @@ public function acceptShare(int $id, ?string $token = null) {
216209
/**
217210
* decline server-to-server share
218211
*
219-
* @param int $id ID of the remote share
212+
* @param string $id ID of the remote share
220213
* @param string|null $token Shared secret between servers
221-
* @return Http\DataResponse<Http::STATUS_OK, list<empty>, array{}>
214+
* @return DataResponse<Http::STATUS_OK, list<empty>, array{}>
222215
* @throws OCSException
223216
*
224217
* 200: Share declined successfully
225218
*/
226219
#[NoCSRFRequired]
227220
#[PublicPage]
228-
public function declineShare(int $id, ?string $token = null) {
221+
public function declineShare(string $id, ?string $token = null) {
229222
$notification = [
230223
'sharedSecret' => $token,
231224
'message' => 'Recipient declined the share'
@@ -249,16 +242,16 @@ public function declineShare(int $id, ?string $token = null) {
249242
/**
250243
* remove server-to-server share if it was unshared by the owner
251244
*
252-
* @param int $id ID of the share
245+
* @param string $id ID of the share
253246
* @param string|null $token Shared secret between servers
254-
* @return Http\DataResponse<Http::STATUS_OK, list<empty>, array{}>
247+
* @return DataResponse<Http::STATUS_OK, list<empty>, array{}>
255248
* @throws OCSException
256249
*
257250
* 200: Share unshared successfully
258251
*/
259252
#[NoCSRFRequired]
260253
#[PublicPage]
261-
public function unshare(int $id, ?string $token = null) {
254+
public function unshare(string $id, ?string $token = null) {
262255
if (!$this->isS2SEnabled()) {
263256
throw new OCSException('Server does not support federated cloud sharing', 503);
264257
}
@@ -275,7 +268,7 @@ public function unshare(int $id, ?string $token = null) {
275268
return new DataResponse();
276269
}
277270

278-
private function cleanupRemote($remote) {
271+
private function cleanupRemote(string $remote): string {
279272
$remote = substr($remote, strpos($remote, '://') + 3);
280273

281274
return rtrim($remote, '/');
@@ -285,16 +278,16 @@ private function cleanupRemote($remote) {
285278
/**
286279
* federated share was revoked, either by the owner or the re-sharer
287280
*
288-
* @param int $id ID of the share
281+
* @param string $id ID of the share
289282
* @param string|null $token Shared secret between servers
290-
* @return Http\DataResponse<Http::STATUS_OK, list<empty>, array{}>
283+
* @return DataResponse<Http::STATUS_OK, list<empty>, array{}>
291284
* @throws OCSBadRequestException Revoking the share is not possible
292285
*
293286
* 200: Share revoked successfully
294287
*/
295288
#[NoCSRFRequired]
296289
#[PublicPage]
297-
public function revoke(int $id, ?string $token = null) {
290+
public function revoke(string $id, ?string $token = null) {
298291
try {
299292
$provider = $this->cloudFederationProviderManager->getCloudFederationProvider('file');
300293
$notification = ['sharedSecret' => $token];
@@ -324,19 +317,19 @@ private function isS2SEnabled($incoming = false) {
324317
}
325318

326319
/**
327-
* update share information to keep federated re-shares in sync
320+
* Update share information to keep federated re-shares in sync.
328321
*
329-
* @param int $id ID of the share
322+
* @param string $id ID of the share
330323
* @param string|null $token Shared secret between servers
331324
* @param int|null $permissions New permissions
332-
* @return Http\DataResponse<Http::STATUS_OK, list<empty>, array{}>
325+
* @return DataResponse<Http::STATUS_OK, list<empty>, array{}>
333326
* @throws OCSBadRequestException Updating permissions is not possible
334327
*
335328
* 200: Permissions updated successfully
336329
*/
337330
#[NoCSRFRequired]
338331
#[PublicPage]
339-
public function updatePermissions(int $id, ?string $token = null, ?int $permissions = null) {
332+
public function updatePermissions(string $id, ?string $token = null, ?int $permissions = null) {
340333
$ncPermissions = $permissions;
341334

342335
try {
@@ -385,7 +378,7 @@ protected function ncPermissions2ocmPermissions($ncPermissions) {
385378
* @param string|null $token Shared secret between servers
386379
* @param string|null $remote Address of the remote
387380
* @param string|null $remote_id ID of the remote
388-
* @return Http\DataResponse<Http::STATUS_OK, array{remote: string, owner: string}, array{}>
381+
* @return DataResponse<Http::STATUS_OK, array{remote: string, owner: string}, array{}>
389382
* @throws OCSBadRequestException Moving share is not possible
390383
*
391384
* 200: Share moved successfully

0 commit comments

Comments
 (0)