Skip to content

poc: Use share manager for space membership#2492

Draft
rhafer wants to merge 7 commits intoopencloud-eu:mainfrom
rhafer:share-manager-for-spaces
Draft

poc: Use share manager for space membership#2492
rhafer wants to merge 7 commits intoopencloud-eu:mainfrom
rhafer:share-manager-for-spaces

Conversation

@rhafer
Copy link
Copy Markdown
Member

@rhafer rhafer commented Mar 17, 2026

This is a proof of concept implementation for #2319. (Persisting Space-Membership in the share-manager)

Requires an adjustment to the CS3 API. Basically just an addtional sharefilter-type: rhafer/cs3apis@6333ce5

The required reva changes are here: https://github.com/rhafer/reva/tree/spaces-in-sharemanager. The rest is mainly accomplished by settting use_common_space_root_share_logic to true. If we decide to move forward with this I'd suggest to remove that option and make the behavior the default. Should get us rid of a bit more code in reva.

As you can see, the changes simplifies the sharing code in the graph service quite a bit as it removes quite a few of the "is this a space root" special cases.

@rhafer rhafer changed the title poc: User share manager for space membershop poc: User share manager for space membership Mar 17, 2026
@rhafer
Copy link
Copy Markdown
Member Author

rhafer commented Mar 17, 2026

cc @aduffeck @butonic @micbar

Copy link
Copy Markdown
Member

@aduffeck aduffeck left a comment

Choose a reason for hiding this comment

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

This looks really nice as a first step.

I suppose in the future we might want to retrieve the list of shared spaces from the space manager too instead of relying on the grants using ListStorageSpaces (analogous to what we do with "regular" shares), but that's something we can discuss later.

"ocmproviderauthorizersvc": cfg.OCMEndpoint,
"ocmcoresvc": cfg.OCMEndpoint,
"commit_share_to_storage_grant": cfg.CommitShareToStorageGrant,
"use_common_space_root_share_logic": true,
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 being used? I didn't find a reference to it in reva.

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.

It's used in the gateway:

https://github.com/opencloud-eu/reva/blob/main/internal/grpc/services/gateway/gateway.go#L79

We should probably remove that config switch, if we decide to switch to the share-manager.

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.

Ah, I thought it was a new flag being introduced with your change. Thanks.

@rhafer rhafer force-pushed the share-manager-for-spaces branch 3 times, most recently from 1460b5f to b0c5b1a Compare March 26, 2026 12:26
@rhafer
Copy link
Copy Markdown
Member Author

rhafer commented Mar 26, 2026

Update, I've addressed many of the failing tests. However there is a few things I can't really fix myself:

  1. Some of the test still fail because they assume a specific format of the permissionId on the SpaceRoots. Up to now for space roots that format was something like u:<grantee-userid> or g:<grantee-groupid> that was however just a crutch and has change now. The permissionId should always be treated as opaque Id. I already fixed that in a lot of places, but the remaining places exceed my php skills

  2. The more difficult part is probably all the failing tests that still use the ocs endpoints. Before diving into fixing ocs we should probably finally decide how to move forward with ocs for sharing (especially for managing space membership). Maybe it is about time to just let is rest in peace. (@micbar @aduffeck @dragotin opinions?) AFAIK we don't have any client that is still using ocs for managing space memberships.

@rhafer rhafer force-pushed the share-manager-for-spaces branch from b0c5b1a to aec01d9 Compare April 8, 2026 14:40
@rhafer rhafer changed the title poc: User share manager for space membership poc: Use share manager for space membership Apr 8, 2026
@rhafer rhafer force-pushed the share-manager-for-spaces branch 2 times, most recently from 82a3c5a to cdebaae Compare April 9, 2026 12:50
@rhafer
Copy link
Copy Markdown
Member Author

rhafer commented Apr 9, 2026

2. The more difficult part is probably all the failing tests that still use the `ocs` endpoints.

The ocs tests are green now. The ocs API is now able to handle the space memberships when they are stored in the ShareProvider.

@rhafer rhafer force-pushed the share-manager-for-spaces branch from cdebaae to bfcd472 Compare April 9, 2026 14:09
@rhafer
Copy link
Copy Markdown
Member Author

rhafer commented Apr 9, 2026

The tests that are still failing are:

  • apiSharingNg1/removeAccessToDrive.feature:132
  • apiSharingNg1/removeAccessToDrive.feature:133
  • apiSharingNg1/removeAccessToDrive.feature:134
  • apiSharingNg1/removeAccessToDrive.feature:137
  • apiSharingNg1/removeAccessToDrive.feature:145
  • apiSharingNg1/removeAccessToDriveItem.feature:123
  • apiSharingNg1/removeAccessToDriveItem.feature:124
  • apiSharingNg1/removeAccessToDriveItem.feature:125
  • apiSharingNg1/removeAccessToDriveItem.feature:143
  • apiSharingNg1/removeAccessToDriveItem.feature:144
  • apiSharingNg1/removeAccessToDriveItem.feature:145

As already mentioned, all of them are failing because the test suite is making wrong assumptions about the format of the permissionid for permissions on Spaces. With this change the permissionId for a space membership does not longer have the format u:<userid> or g:<groupid>. The IDs should just be treated as opaque ids (similar to permissions on folder and files).

So to remove the access of a specific user from a space. One needs to first list the permissions on that space and then pick the permission id of the permission that belongs to the user.

@ScharfViktor would be cool if you could take a look into this. This is a bit above my PHP level. For many of the other failures I've worked around this by just recording the id using shareNgAddToCreatedUserGroupShares maybe that could work here as well, I am unsure.

@ScharfViktor ScharfViktor self-assigned this Apr 11, 2026
@ScharfViktor
Copy link
Copy Markdown
Contributor

apiSharingNg1/removeAccessToDrive.feature:137
apiSharingNg1/removeAccessToDrive.feature:145

still failed because user can remove own access even he is the last space manager

Scenario: user cannot remove himself from the project space if he is the last manager using root endpoint # /Users/v.scharf/Work/opencloud/opencloud/tests/acceptance/features/apiSharingNg1/removeAccessToDrive.feature:137
    Given the administrator has assigned the role "Space Admin" to user "Alice" using the Graph API         # GraphContext::theAdministratorHasGivenTheRoleUsingTheGraphApi()
    And user "Alice" has created a space "NewSpace" with the default quota using the Graph API              # SpacesContext::theUserHasCreatedASpaceByDefaultUsingTheGraphApi()
    When user "Alice" tries to remove own access from space "NewSpace" using root endpoint of the Graph API # SharingNgContext::userRemovesOwnAccessFromSpaceUsingGraphAPI()
    Then the HTTP status code should be "403"                                                               # FeatureContext::thenTheHTTPStatusCodeShouldBe()
      HTTP status code 204 is not the expected value 403
      Failed asserting that 204 matches expected '403'.
    And the user "Alice" should have a space called "NewSpace"   

rhafer added 3 commits April 13, 2026 15:35
This gets us rid of quite a bit of special casing for space permission.
Also provides us with "real" permission IDs instead of those faked
"u:<userid>" ones.
The `id` property of the `permissions` on a space root does not
longer have that special `u:<userid>` format any. It now has the
same format as the permission id on "normal" driveItems.
default => throw new Exception("shareType '$shareType' does not match user|group|link "),
};
// if recipient is not provided, it means user tries to remove own access, then we need to get the user permission id
if (!isset($recipient)) {
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.

@ScharfViktor This breaks userRemovesLinkFromSpaceUsingRootEndpointOfGraphAPI() I think.
It calls $this->removeAccessToSpace($sharer, 'link', $space) (so $recipient is unset). But it would need $permissionID be set to $this->featureContext->shareNgGetLastCreatedLinkShareID() because of $shareType='link'

@rhafer rhafer force-pushed the share-manager-for-spaces branch from 64bb3f5 to 1f91075 Compare April 13, 2026 15:46
@rhafer
Copy link
Copy Markdown
Member Author

rhafer commented Apr 13, 2026

apiSharingNg1/removeAccessToDrive.feature:137
apiSharingNg1/removeAccessToDrive.feature:145

still failed because user can remove own access even he is the last space manager

Scenario: user cannot remove himself from the project space if he is the last manager using root endpoint # /Users/v.scharf/Work/opencloud/opencloud/tests/acceptance/features/apiSharingNg1/removeAccessToDrive.feature:137
    Given the administrator has assigned the role "Space Admin" to user "Alice" using the Graph API         # GraphContext::theAdministratorHasGivenTheRoleUsingTheGraphApi()
    And user "Alice" has created a space "NewSpace" with the default quota using the Graph API              # SpacesContext::theUserHasCreatedASpaceByDefaultUsingTheGraphApi()
    When user "Alice" tries to remove own access from space "NewSpace" using root endpoint of the Graph API # SharingNgContext::userRemovesOwnAccessFromSpaceUsingGraphAPI()
    Then the HTTP status code should be "403"                                                               # FeatureContext::thenTheHTTPStatusCodeShouldBe()
      HTTP status code 204 is not the expected value 403
      Failed asserting that 204 matches expected '403'.
    And the user "Alice" should have a space called "NewSpace"   

I've bumped reva to opencloud-eu/reva@90717df that should have fixed it.

@ScharfViktor
Copy link
Copy Markdown
Contributor

I've bumped reva to opencloud-eu/reva@90717df that should have fixed it.

I can confirm, that it fixed

We now report a quota of -3 for unlimited quota instead of 0, which
clients interpreted as a quota of 0.
@sonarqubecloud
Copy link
Copy Markdown

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants