Repository navigation
[feature/guest-links] Manage space membership in shareprovider - #593
Conversation
|
depends on cs3org/cs3apis#265. Apart from that, I think this is ready for review. |
| } | ||
| 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") |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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()) { |
There was a problem hiding this comment.
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.
| return p, err == nil | ||
| func (h *Handler) isSpaceShare(r *http.Request, shareID string) bool { | ||
| _, err := storagespace.ParseReference(shareID) | ||
| return err == nil |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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)
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".
Avoid duplicating code in all managers
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.
f629059 to
1b04d5f
Compare
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.
1b04d5f to
ae99c47
Compare
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]>
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]>
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:
use_common_space_root_share_logicswitch from the gateway and make it the default behaviour. (That would remove a few more line on unneeded code