Skip to content

fix(ocm): align ocm share permissions with the shared resource type - #1035

Merged
butonic merged 9 commits into
opencloud-eu:mainfrom
butonic:port-wp4-807-808-809-812
Nov 19, 2026
Merged

butonic merged 9 commits into
opencloud-eu:mainfrom
butonic:port-wp4-807-808-809-812

Conversation

@butonic

@butonic butonic commented Nov 18, 2026

Copy link
Copy Markdown
Member

Four fixes to how OCM share permissions end up on the shared resource and on the received share:

  • creating an OCM share no longer adds a storage grant when the share provider failed, e.g. because the federated instance is unreachable.
  • updating an OCM share now also updates the storage grant on the resource, which kept the permissions from share creation.
  • the editor permission set of a received share no longer contains ListGrants, and the share permission no longer grants Reshare.
  • CreateContainer, Delete and Move are only granted for folder shares. /shares and the permission change notification pass the resource type to ToOCMProtocol, so a file share gets the file editor permissions.

Review focus:

  • gateway.UpdateOCMShare: the last commit returns early when the share update failed and takes the grant permissions from the webdav access method instead of AccessMethods[0], which panicked on a share without access methods. CreateOCMShare still uses AccessMethods[0] like before.
  • a notification or share request without a resourceType now only gets the file permissions for write. resourceType is required by the OCM spec and validated on both endpoints.

Review commit by commit: the first four carry the original fixes, the last one is ours and adds a test for the file/folder permissions.

stacked on #1030, only the last five commits belong to this PR.

AI assistance: Claude Code (claude-opus-5-5) cherry-picked the fixes, resolved the conflicts, wrote the gateway guard, the test and this description.

2403905 and others added 7 commits November 17, 2026 18:09
When the owner removes an OCM share we now notify the receiving
instance with a SHARE_UNSHARED notification on its /notifications
endpoint. The receiver deletes the received share through the new
DeleteOCMCoreShare implementation, so remote users no longer keep a
dangling share pointing at a resource they cannot access anymore.

A failing notification is logged and does not fail the removal.

Signed-off-by: Jörn Friedrich Dreyer <[email protected]>
Updating the permissions of an OCM share now sends a
SHARE_CHANGE_PERMISSION notification to the receiving instance, which
updates the permissions of the received share through
UpdateOCMCoreShare. Before, the remote kept the permissions it got when
the share was created.

The notification payload moves from pkg/ocm/payload into the ocm client
package.

Signed-off-by: Jörn Friedrich Dreyer <[email protected]>
The ocmcore service now publishes OCMCoreShareCreated when a remote
instance creates a share for one of our users, and the new
OCMCoreShareDelete when the remote removes it again. The events are
sent directly when an events endpoint is configured, so they no longer
depend on the events middleware being configured on the ocm grpc
server, which it is not. Consumers like userlog can turn them into
notifications for the receiving user.

Signed-off-by: Jörn Friedrich Dreyer <[email protected]>
The /notifications endpoint is unauthenticated, and a notification
without a notification object, or with a content type other than
application/json, made the handler dereference a nil request and
panic. Several error paths also wrote an error response and then fell
through to write another status. We now return 400 for these requests
before touching the gateway, require the protocol for permission
changes and stop after every error response.

Unsharing a share the receiver no longer knows now answers 404 instead
of failing with an internal error, so a repeated notification is not
reported as a server error.

Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Jörn Friedrich Dreyer <[email protected]>
The gateway added the storage grant for a new OCM share without looking
at the status the ocm share provider returned. When the federated
instance was unreachable the share was not created, but the resource
still got a grant for the remote user. We now return the error status
before touching the storage provider.

Signed-off-by: Jörn Friedrich Dreyer <[email protected]>
Updating the permissions of an OCM share only changed the share in the
ocm share provider. The grant on the shared resource kept the old
permissions. The gateway now fetches the updated share and updates the
grant with its webdav permissions and expiration.

Signed-off-by: Jörn Friedrich Dreyer <[email protected]>
The write permission of an incoming webdav protocol also granted
ListGrants, and the share permission granted Reshare. Neither belongs
to the editor role, so the received share showed up with a role that
does not match any of ours.

Signed-off-by: Jörn Friedrich Dreyer <[email protected]>
2403905 and others added 2 commits November 19, 2026 10:09
The write permission of an incoming webdav protocol always granted
CreateContainer, Delete and Move. On a file share those don't match the
file editor role. We now pass the resource type of the share or
notification to ToOCMProtocol and only add them for folders.

Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Jörn Friedrich Dreyer <[email protected]>
The gateway synced the storage grant even when the ocm share provider
failed to update the share, e.g. because the remote could not be
notified and the update was reverted. It also took the permissions
from the first access method and panicked on a share without access
methods. We now return the error status first and use the permissions
of the webdav access method, skipping the grant when there is none.

Also adds a test for the permissions ToOCMProtocol derives for file
and folder shares.

Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Jörn Friedrich Dreyer <[email protected]>
@butonic
butonic force-pushed the port-wp4-807-808-809-812 branch from 5a7651a to 04c5ccb Compare November 19, 2026 09:31
@butonic butonic self-assigned this Nov 19, 2026
butonic added a commit to opencloud-eu/opencloud that referenced this pull request Nov 19, 2026
We temporarily replace reva with the butonic fork at a merge of reva
main and opencloud-eu/reva#1035, which is
stacked on opencloud-eu/reva#1030. This brings
in the OCM unshare and permission change notifications, the ocm core
share events and the fixes to the permissions of OCM shares, on top of
the invite and provider fixes already on reva main.

Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Jörn Friedrich Dreyer <[email protected]>
@butonic
butonic requested a review from fschade November 19, 2026 10:49
@butonic
butonic merged commit 0093d72 into opencloud-eu:main Nov 19, 2026
19 checks passed
@openclouders openclouders mentioned this pull request Nov 19, 2026
1 task
butonic added a commit to opencloud-eu/opencloud that referenced this pull request Nov 19, 2026
We bump reva to 0093d72f4c9d, the merge of
opencloud-eu/reva#1035 on reva main. This
brings in the OCM unshare and permission change notifications, the ocm
core share events and the fixes to the permissions of OCM shares, on
top of the invite and provider fixes already on reva main.

It also pulls in the revision cleanup from
opencloud-eu/reva#895. Its strategy defaults
to empty, which keeps all revisions, so nothing changes until we wire
up the option.

Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Jörn Friedrich Dreyer <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants