Skip to content

usershareprovider: tighten space manager checks - #993

Merged
butonic merged 2 commits into
opencloud-eu:workpackagesfrom
butonic:backport-wp2-631-653
Nov 11, 2026
Merged

butonic merged 2 commits into
opencloud-eu:workpackagesfrom
butonic:backport-wp2-631-653

Conversation

@butonic

@butonic butonic commented Nov 11, 2026

Copy link
Copy Markdown
Member

Two space membership fixes for the share provider, one commit each:

  • owncloud/reva#631: an expiration can no longer be set on the last permanent manager of a space. Once it expired the space had no manager left. The last manager check in UpdateShare now also runs when a manager share ends up with an expiration
  • owncloud/reva#653: space root shares that carry some grant management bits without the full manager permissions (e.g. viewer + RemoveGrant) are rejected on create and update. decomposedfs IsManager/IsEditor/IsViewer become IsSpaceManager/IsSpaceEditor/IsSpaceViewer and check the role bitmaps instead of a single bit

Upstream did both in the gateway (updateSpaceShare/addSpaceShare). Since #593 space membership lives in the share provider, so the checks go into CreateShare/UpdateShare there, next to the last manager check that #990 made ignore expiring managers.

Side effect of 653: OCS requests that share a space with a partial permission set (e.g. the coowner role, which lacks DenyGrant) now get a 400. Same as upstream. I verified that the graph Manager role maps to the full manager bitmap, so graph invites are not affected.

The server half of 653 (owncloud/ocis#12540) follows in a bump PR against workpagages in opencloud.

go test ./internal/... ./pkg/storage/... ./pkg/share/... ./pkg/conversions/... is green. The new specs fail without the fixes.

This is based on workpackages, which does not have #986 yet. 653 also touches decomposedfs/spaces.go, but only the three role helper calls, so merging main into workpackages should not conflict there.

AI assistance: Claude Code (claude-opus-5-5) ported both changes to the share provider, wrote the specs and ran the tests.

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
opencloud-eu#593, so the check goes into
UpdateShare next to the existing one, which ignores expiring managers
since opencloud-eu#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
opencloud-eu#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]>
@butonic
butonic marked this pull request as ready for review November 11, 2026 12:49
@butonic butonic added the Type:Maintenance E.g. technical debt, packaging, etc. label Nov 11, 2026
@butonic butonic self-assigned this Nov 11, 2026
@butonic
butonic merged commit fa3c9e2 into opencloud-eu:workpackages Nov 11, 2026
20 checks passed
dragonchaser added a commit to dragonchaser/reva that referenced this pull request Nov 11, 2026
Resolve the usershareprovider.go conflict in favour of opencloud-eu#993, which landed the same last manager expiration check first. Its mayRemoveLastPermanentManager is the more precise variant: it resolves the permissions and expiration an update leaves on the share, so only expiring managers trigger the check.

Drop this branch's specs that opencloud-eu#993 covers with the same or stronger scenarios and keep the one it lacks: an expiration in the payload is ignored when the update mask does not list it.

Co-authored-by: Copilot <[email protected]>
butonic added a commit to opencloud-eu/opencloud that referenced this pull request Nov 12, 2026
Picks up the space manager checks from
opencloud-eu/reva#990 and
opencloud-eu/reva#993.

go-chi and go-jose move up because reva requires the newer versions.

Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Jörn Friedrich Dreyer <[email protected]>
butonic added a commit to pbleser-oc/opencloud that referenced this pull request Nov 13, 2026
Updating a permission or a space root permission did not check the
roles an administrator enabled with GRAPH_AVAILABLE_ROLES. An invite
with a disabled role was rejected, but the same role could be set by
updating an existing share. We now validate updates against the
allowlist, same as invites.

The three "without enabling it" scenarios now expect a 400. Their
removed lines are padded with blank lines so the line numbers of the
scenarios stay the same.

ported from `owncloud/ocis#12540`. The reva half
(`owncloud/reva#653`) is opencloud-eu/reva#993

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

Type:Maintenance E.g. technical debt, packaging, etc.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants