Skip to content

[feature/guest-links] Manage space membership in shareprovider - #593

Merged
rhafer merged 16 commits into
opencloud-eu:feature/guest-linksfrom
rhafer:spaces-in-sharemanager
Apr 23, 2026
Merged

rhafer merged 16 commits into
opencloud-eu:feature/guest-linksfrom
rhafer:spaces-in-sharemanager

Conversation

@rhafer

@rhafer rhafer commented Apr 15, 2026 •

Copy link
Copy Markdown
Member

This is the reva part for: opencloud-eu/opencloud#2319

It requires a small adjustment to the CS3 APIs: rhafer/cs3apis@3c8cce6

What is missing before we can merge this:

  • remove the use_common_space_root_share_logic switch from the gateway and make it the default behaviour. (That would remove a few more line on unneeded code
  • figure out a migration so that existing setups will get their spacemembership migrated to the shareprovider

@rhafer

rhafer commented Apr 15, 2026

Copy link
Copy Markdown
Member Author

depends on cs3org/cs3apis#265. Apart from that, I think this is ready for review.

@rhafer
rhafer requested review from aduffeck, dragonchaser and dragotin and removed request for dragotin April 15, 2026 09:25
@rhafer
rhafer marked this pull request as draft April 15, 2026 09:26
}
csResp, err := s.CreateShare(ctx, shareReq)
if err != nil || csResp.GetStatus().GetCode() != rpc.Code_CODE_OK {
log.Error().Err(err).Interface("status", csResp.GetStatus()).Interface("space_id", createRes.GetStorageSpace().GetId()).Msg("failed to create share for space owner")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should we handle this error case more thoroughly?
Once we get the list of spaces for /me/drives from the share manager this space would be dangling. So maybe we should rather delete the space and return an error here?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Hm, true. We're trying to rollback now.

o := utils.AppendJSONToOpaque(nil, "resourceid", share.GetResourceId())
o = utils.AppendPlainToOpaque(o, "resourcename", sRes.GetInfo().GetName())
var opaque *typesv1beta1.Opaque
if utils.IsSpaceRoot(sRes.GetInfo()) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

There are several places where we set the spacegrant opaque entry. I wonder if it makes sense to put that into a shared utility function.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

✔️

return p, err == nil
func (h *Handler) isSpaceShare(r *http.Request, shareID string) bool {
_, err := storagespace.ParseReference(shareID)
return err == nil

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is this actually correct? storagespace.ParseReference only parses a string reference into a provider.Reference, it doesn't return an error when the ref is not a space root so I don't think this method does what it claims it does unless I'm missing something.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yeah right. That check is somewhat bogus now. Need take a closer look at the original implementation again what it actually supports.

Did we really allow References (with Paths) to be used as the shareid on: DELETE /apps/files_sharing/api/v1/shares/(shareid) ? That seems rather strange. I strongly believe the intention was to only allow ResourceIds here.

(Sidenote: I don't believe we have any client left using this API, apart from the test suite in opencloud 🤷‍♂️ , and that one only uses space IDs IIRC. I'll double check)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done

rhafer added 13 commits April 22, 2026 11:35
Grants on SpaceRoots still require the "spacegrant" and "spacetype"
Opaque.
For managing space memberships via the sharemanager we need to loosen
the resharing restriction a bit. As adding a new space manager is
basically "resharing".
Up to now we sent the SpaceShared/SpaceUnshared/SpaceShareUpdated events
as part of the Add/Remvove/UpdateGrant calls. With the recent changes to
handle Space Membership via the Share manager this resulted in
two Events being sent when a Space was shared, one for the ShareCreation
and one of the AddGrant. With this change we send the Space related
events as part of the Create/Delete/UpdateShare calls.

Unfortunately this means we need to add yet another Opaque field to the
responses from the ShareProvider to indicate that the thare being
accessed was actually targeting a SpaceRoot.
Currently the storage driver is responsible for adding an initial Grant
to the SpaceRoot to give the creator of a space the "manager"
permssions. With the share manager becoming the primary source for space
membership we now to create that initial share as part of the
CreateStorageSpace call in the gateway.
The check is done in the shareprovider now not in the space specific
code in the gateway.
Some callers (e.g. the graph API) currently only set the OpaqueId of
the Grantee, without populating the IDP and Type properties. For User
shares we already set those to fallback values. This was missing for
Group shares.
This reworks some of the special case handling that the ocs service
did for managing space shares. This is mainly for making the acceptance
test working in OpenCloud. I don't think any real world client is still
using ocs for sharing spaces. Anyway, with this change this should still
work.
previously the acceptance tests worked just because of side-effects in
the Handlers for the `/apps/files_sharing/api/v1/shares/{shareid}` route.

Now, if `apps/files_sharing/api/v1/shares/pending` is called without a
{shareId}, we have explicit routes for that.
This check was previously done by the Gateway, when updating
the grants on the SpaceRoot.
The permissions check for share removal was moved from the
manager/driver to shareprovider we forgot to update the unittest
accordingly.
@rhafer
rhafer force-pushed the spaces-in-sharemanager branch from f629059 to 1b04d5f Compare April 22, 2026 09:36
@rhafer
rhafer marked this pull request as ready for review April 22, 2026 09:36
@rhafer
rhafer requested a review from aduffeck April 22, 2026 09:36
rhafer added 3 commits April 22, 2026 14:34
When we can't create the initial "owner" share for a new space, we now
delete the created space to not leave any dangling space behind.
Adds unit test as well.
Verify that the resource id returned from 'ParseReference' actually
looks like a space id.
@rhafer
rhafer force-pushed the spaces-in-sharemanager branch from 1b04d5f to ae99c47 Compare April 22, 2026 12:34

@aduffeck aduffeck left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

👍 lgtm

@rhafer
rhafer merged commit 11463a5 into opencloud-eu:feature/guest-links Apr 23, 2026
1 check passed
@openclouders openclouders mentioned this pull request May 13, 2026
1 task
butonic added a commit that referenced this pull request Nov 11, 2026
A space manager share could get an expiration even when it was the
last permanent manager of the space. Once it expired the space was
left without a manager. The last manager check in UpdateShare only ran
when the new permissions stripped AddGrant or RemoveGrant.

We now also run it when the share keeps the manager permissions but
ends up with an expiration, either from the update or because it
already had one and only the permissions change. Removing an
expiration does not need the check.

Upstream did this in the gateway, where space grants were still
handled at the time (`owncloud#631`). Our space membership lives
in the share provider since
#593, so the check goes into
UpdateShare next to the existing one, which ignores expiring managers
since #990.

Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Jörn Friedrich Dreyer <[email protected]>
butonic added a commit that referenced this pull request Nov 11, 2026
A space share could carry a single grant management bit, e.g. viewer
permissions plus RemoveGrant. decomposedfs treated RemoveGrant alone as
the manager marker, so such a grantee could manage the space while the
UI showed a viewer.

The share provider now rejects space root shares that carry any of
AddGrant, UpdateGrant, RemoveGrant or DenyGrant without the full
manager permissions, both on create and on update. In decomposedfs
IsManager, IsEditor and IsViewer become IsSpaceManager, IsSpaceEditor
and IsSpaceViewer and check the role bitmaps instead of a single bit.
A space manager needs AddGrant, UpdateGrant and RemoveGrant. DenyGrant
is not required, so older manager and coowner grants still count.

Upstream put the share check into the gateway (`owncloud#653`).
Space membership lives in the share provider since
#593, so the check goes into
CreateShare and UpdateShare there. Update requests are checked against
the effective new permissions, the same ones the last manager check
uses.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants