Skip to content

Feat/federated sharing - #8184

Open
luka-nextcloud wants to merge 14 commits into
mainfrom
feat/federated-sharing
Open

luka-nextcloud wants to merge 14 commits into
mainfrom
feat/federated-sharing

Conversation

@luka-nextcloud

@luka-nextcloud luka-nextcloud commented Jul 21, 2026 •

Copy link
Copy Markdown
Contributor
  • Resolves: #
  • Target version: main

Summary

TODO

  • ...

Checklist

  • Code is properly formatted
  • Sign-off message is added to all commits
  • Tests (unit, integration, api and/or acceptance) are included
  • Documentation (manuals or wiki) has been updated or is not required

@github-actions

Copy link
Copy Markdown
Contributor

🐢 Performance warning.
It looks like the query count of the integration tests increased with this PR.
Database query count is now 96828 was 96706 (+0.12%)
Please check your code again. If you added a new test this can be expected and the base value in tests/integration/base-query-count.txt can be increased.

@github-actions

Copy link
Copy Markdown
Contributor

🐢 Performance warning.
It looks like the query count of the integration tests increased with this PR.
Database query count is now 206554 was 198420 (+4.09%)
Please check your code again. If you added a new test this can be expected and the base value in tests/integration/base-query-count.txt can be increased.

@luka-nextcloud

Copy link
Copy Markdown
Contributor Author

@CarlSchwan @come-nc I would need advice from experts of files_sharing app:
What is the correct way to mount the endpoint and ensure the remote share file is visible right after accepted the remote share (after called $this->externalManager->acceptShare($externalShare))?

@luka-nextcloud
luka-nextcloud force-pushed the feat/federated-sharing branch from 1eca4c9 to 38e34df Compare October 6, 2026 06:58
@github-actions

github-actions Bot commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

🐢 Performance warning.
It looks like the query count of the integration tests increased with this PR.
Database query count is now 205527 was 198420 (+3.58%)
Please check your code again. If you added a new test this can be expected and the base value in tests/integration/base-query-count.txt can be increased.

@github-actions

github-actions Bot commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

🐢 Performance warning.
It looks like the query count of the integration tests increased with this PR.
Database query count is now 205990 was 198420 (+3.81%)
Please check your code again. If you added a new test this can be expected and the base value in tests/integration/base-query-count.txt can be increased.

@luka-nextcloud
luka-nextcloud marked this pull request as ready for review October 20, 2026 09:02
@github-actions

Copy link
Copy Markdown
Contributor

🐢 Performance warning.
It looks like the query count of the integration tests increased with this PR.
Database query count is now 202736 was 198420 (+2.17%)
Please check your code again. If you added a new test this can be expected and the base value in tests/integration/base-query-count.txt can be increased.

@benjaminfrueh benjaminfrueh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@luka-nextcloud thanks for working on this! I left some comments, mostly about the attachment part.

One more general thing: the PR doesn't add tests for the new federation code yet. It would be great to have some.

The PR description is still empty. Could you add a short summary of what's included and how to test it?

Comment thread lib/Cron/ScanFederatedAttachment.php Resolved
Comment thread lib/Sharing/DeckShareProvider.php Resolved
Comment thread lib/Service/FilesAppService.php Resolved
Comment thread lib/Service/PermissionService.php Outdated
// check for users
foreach ($acls as $acl) {
if ($acl->getType() === Acl::PERMISSION_TYPE_USER && $acl->getParticipant() === $userId) {
if (in_array($acl->getType(), [Acl::PERMISSION_TYPE_USER, Acl::PERMISSION_TYPE_REMOTE]) && $acl->getParticipant() === $userId) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This now also matches remote ACLs by participant ID. Since local user IDs can contain @, a local user whose ID is the same as a remote participants cloud ID (e.g. user1@other.server) would get that remote participants permissions. Could we keep remote ACLs out of userCan() and handle the federated case separately?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This still compares the remote user cloud ID with the local user ID, so a local user whose ID is the same as a remote participant's cloud ID still gets their permissions. I tested and such a local user can read the board and create cards.

Since only DeckShareProvider::create() needs this for the remote sharedBy, maybe keep userCan() for local users only and check remote participants there explicitly, e.g.:

if ($this->userManager->userExists($sharedBy)) {
	// existing checkPermission() for local users
} elseif (!$this->permissionService->remoteParticipantCan($boardId, $sharedBy, Acl::PERMISSION_EDIT)) {
	$valid = false;
}

with remoteParticipantCan() only checking PERMISSION_TYPE_REMOTE ACLs and probably also checking that federation is enabled like externalUserCan() does.

Comment thread lib/Cron/ScanFederatedAttachment.php Resolved
Comment thread lib/Cron/ScanFederatedAttachment.php Resolved
Comment thread lib/Service/FilesAppService.php Resolved
Comment thread lib/Sharing/DeckShareProvider.php Resolved
Comment thread lib/Sharing/DeckShareProvider.php Resolved
Signed-off-by: Luka Trovic <luka@nextcloud.com>
Signed-off-by: Luka Trovic <luka@nextcloud.com>
Signed-off-by: Luka Trovic <luka@nextcloud.com>
Signed-off-by: Luka Trovic <luka@nextcloud.com>
Signed-off-by: Luka Trovic <luka@nextcloud.com>
Signed-off-by: Luka Trovic <luka@nextcloud.com>
Signed-off-by: Luka Trovic <luka@nextcloud.com>
Signed-off-by: Luka Trovic <luka@nextcloud.com>
Signed-off-by: Luka Trovic <luka@nextcloud.com>
Signed-off-by: Luka Trovic <luka@nextcloud.com>
Signed-off-by: Luka Trovic <luka@nextcloud.com>
Signed-off-by: Luka Trovic <luka@nextcloud.com>
Signed-off-by: Luka Trovic <luka@nextcloud.com>

@benjaminfrueh benjaminfrueh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@luka-nextcloud thanks for the updates, a lot of things are fixed and improved now 🚀

I did a second round of review and added some follow-ups, mostly around the remote user check, the cleanup when someone leaves, the files_sharing dependency and the comment mentions.

More generally: the share lookups are now spread as raw queries across RemoteShareHelper, FilesAppService and DeckShareProvider. Moving them into one place, e.g. a FederatedShareMapper like the existing mappers, would make the logic easier to follow and to test.

Tests for the new federation code and a short PR description with what's included and how to test it would still be great.

Comment thread lib/Service/AttachmentService.php Resolved
Comment thread lib/Sharing/RemoteShareHelper.php Resolved
Comment thread lib/Sharing/RemoteShareHelper.php Resolved
Comment thread lib/Service/PermissionService.php Outdated
// check for users
foreach ($acls as $acl) {
if ($acl->getType() === Acl::PERMISSION_TYPE_USER && $acl->getParticipant() === $userId) {
if (in_array($acl->getType(), [Acl::PERMISSION_TYPE_USER, Acl::PERMISSION_TYPE_REMOTE]) && $acl->getParticipant() === $userId) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This still compares the remote user cloud ID with the local user ID, so a local user whose ID is the same as a remote participant's cloud ID still gets their permissions. I tested and such a local user can read the board and create cards.

Since only DeckShareProvider::create() needs this for the remote sharedBy, maybe keep userCan() for local users only and check remote participants there explicitly, e.g.:

if ($this->userManager->userExists($sharedBy)) {
	// existing checkPermission() for local users
} elseif (!$this->permissionService->remoteParticipantCan($boardId, $sharedBy, Acl::PERMISSION_EDIT)) {
	$valid = false;
}

with remoteParticipantCan() only checking PERMISSION_TYPE_REMOTE ACLs and probably also checking that federation is enabled like externalUserCan() does.

Comment thread lib/Sharing/RemoteShareHelper.php Resolved
Comment thread lib/Sharing/RemoteShareHelper.php Resolved
Comment thread lib/Sharing/RemoteShareHelper.php Resolved
Comment thread lib/Sharing/RemoteShareHelper.php Resolved
Comment thread lib/Service/ExternalBoardService.php Resolved
Comment thread lib/Sharing/RemoteShareHelper.php Resolved
Signed-off-by: Luka Trovic <luka@nextcloud.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants