Files
opencloud/services/ocm
Jörn Friedrich Dreyer d7b309f9cf feat(userlog): notify users about received ocm shares
Users never got a notification when a federated instance shared
something with them or removed that share again. The ocmcore service
publishes OCMCoreShareCreated and OCMCoreShareDelete, but only when it
has an events config, and the ocm service never passed one.

We now pass the events config to ocmcore, and userlog turns both
events into the regular "Resource shared" / "Resource unshared"
notifications for the grantee. They honor the same in-app settings as
local shares.

The sharer is a federated user, so we look it up with GetAcceptedUser in
the name of the grantee. That call has to go out without the service
account token, otherwise the invite manager filters by the service
account and finds nothing. If the lookup fails, e.g. because the
federated connection was deleted, the notification says "Someone at
<provider domain> shared <resource> with you" instead of showing an
empty name. The federated id itself is "<uuid>@<issuer url>", which
tells the reader nothing. Clients only fill in the known rich
parameters, so we fill in the provider in the rich message ourselves.

The resource lives on the remote instance. The notification points to
the received share id for both events and carries the resource name
without an id, so clients render it like a local share but don't build
a link to a resource that does not exist here.

Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
2026-12-04 16:48:17 +01:00
..

OCM

The ocm service provides federated sharing functionality based on the sciencemesh and ocm HTTP APIs. Internally the ocm service consists of the following services and endpoints:

External HTTP APIs:

  • sciencemesh: serves the API for the invitation workflow
  • ocmd: serves the API for managing federated shares

Internal GRPC APIs:

  • ocmproviderauthorizer: manages the list of trusted providers and verifies requests
  • ocminvitemanager: manages the list and state of invite tokens
  • ocmshareprovider: manages ocm shares on the sharer
  • ocmcore: used for creating federated shares on the receiver side
  • authprovider: authenticates webdav requests using the ocm share tokens

Enable OCM

To enable OpenCloudMesh, you have to set the following environment variable.

OC_ENABLE_OCM=true

Trust Between Instances

The ocm services implements an invitation workflow which needs to be followed before creating federated shares. Invitations are limited to trusted instances, however.

The list of trusted instances is managed by the ocmproviderauthorizer service. The only supported backend currently is json which stores the list in a json file on disk. Note that the ocmproviders.json file, which holds that configuration, is expected to be located in the root of the OpenCloud config directory if not otherwise defined. See the OCM_OCM_PROVIDER_AUTHORIZER_PROVIDERS_FILE envvar for more details.

When all instances of a federation should trust each other, an ocmproviders.json file like this can be used for all instances:

[
    {
        "name": "OpenCloud Test 1",
        "full_name": "OpenCloud Test provider 1",
        "organization": "OpenCloud One",
        "domain": "cloud1.opencloud.test",
        "homepage": "https://cloud1.opencloud.test",
        "description": "First OpenCloud Example cloud storage",
        "services": [
            {
                "endpoint": {
                    "type": {
                        "name": "OCM",
                        "description": "cloud1.opencloud.test Open Cloud Mesh API"
                    },
                    "name": "cloud1.opencloud.test - OCM API",
                    "path": "https://cloud1.opencloud.test/ocm/",
                    "is_monitored": true
                },
                "api_version": "0.0.1",
                "host": "http://cloud1.opencloud.test"
            },
            {
                "endpoint": {
                    "type": {
                        "name": "Webdav",
                        "description": "cloud1.opencloud.test Webdav API"
                    },
                    "name": "cloud1.opencloud.test Example - Webdav API",
                    "path": "https://cloud1.opencloud.test/dav/",
                    "is_monitored": true
                },
                "api_version": "0.0.1",
                "host": "https://cloud1.opencloud.test/"
            }
        ]
    },
    {
        "name": "OpenCloud Test 2",
        "full_name": "OpenCloud Test provider 2",
        "organization": "OpenCloud Two",
        "domain": "cloud2.opencloud.test",
        "homepage": "https://cloud2.opencloud.test",
        "description": "Second OpenCloud Example cloud storage",
        "services": [
            {
                "endpoint": {
                    "type": {
                        "name": "OCM",
                        "description": "cloud2.opencloud.test Open Cloud Mesh API"
                    },
                    "name": "cloud2.opencloud.test - OCM API",
                    "path": "https://cloud2.opencloud.test/ocm/",
                    "is_monitored": true
                },
                "api_version": "0.0.1",
                "host": "http://cloud2.opencloud.test"
            },
            {
                "endpoint": {
                    "type": {
                        "name": "Webdav",
                        "description": "cloud2.opencloud.test Webdav API"
                    },
                    "name": "cloud2.opencloud.test Example - Webdav API",
                    "path": "https://cloud2.opencloud.test/dav/",
                    "is_monitored": true
                },
                "api_version": "0.0.1",
                "host": "https://cloud2.opencloud.test/"
            }
        ]
    }
]

:::info Note: the domain must not contain the protocol as it has to match the GOCDB site object domain. :::

The above federation consists of two instances: cloud1.opencloud.test and cloud2.opencloud.test that can use the Invitation workflow described below to generate, send and accept invitations.

Invitation Workflow

Before sharing a resource with a remote user this user has to be invited by the sharer.

In order to do so a POST request is sent to the generate-invite endpoint of the sciencemesh API. The generated token is passed on to the receiver, who will then use the accept-invite endpoint to accept the invitation. As a result remote users will be added to the ocminvitemanager on both sides. See invitation flow for the according sequence diagram.

The data backend of the ocminvitemanager is configurable. The only supported backend currently is json which stores the data in a json file on disk.

Creating Shares

:::info The below info is outdated as we allow creating federated shares using the graph API. Clients can now discover the available sharing roles and invite federated users using the graph API. :::

OCM Shares are currently created using the ocs API, just like regular shares. The difference is the share type, which is 6 (ShareTypeFederatedCloudShare) in this case, and a few additional parameters required for identifying the remote user.

See Create share flow for the according sequence diagram.

The data backends of the ocmshareprovider and ocmcore services are configurable. The only supported backend currently is json which stores the data in a json file on disk.