Skip to content

fix(gateway): prevent setting an expiration on the last space manager - #631

Merged
2403905 merged 1 commit into
owncloud:mainfrom
dj4oC:fix/space-last-manager-expiration
Jul 6, 2026
Merged

2403905 merged 1 commit into
owncloud:mainfrom
dj4oC:fix/space-last-manager-expiration

Conversation

@dj4oC

@dj4oC dj4oC commented Jun 13, 2026

Copy link
Copy Markdown

Problem

Fixes the behaviour behind owncloud/ocis#11205: an expiration date can be set on the last Manager of a space. Once that grant expires, the space is left without any manager.

Root cause

updateSpaceShare (internal/grpc/services/gateway/usershareprovider.go) guards against orphaning a space by calling isSpaceManagerRemaining before applying a grant. That guard was gated behind if !grant.GetPermissions().GetRemoveGrant() — i.e. it only ran when the grant was dropping the manager role. Setting an expiration on a grant that keeps the manager role (RemoveGrant stays true) skipped the check entirely, so an expiring grant could be written onto the only permanent manager.

isSpaceManagerRemaining already counts only permanent managers (Expiration == nil, excluding the grantee being updated), so it has everything it needs — it just wasn't being consulted in the expiration case.

Fix

Run the remaining-manager check whenever the update could remove the last permanent manager — either by dropping the manager role or by giving a manager grant an expiration:

func mayRemoveLastPermanentManager(grant *provider.Grant) bool {
    return !grant.GetPermissions().GetRemoveGrant() || grant.GetExpiration() != nil
}

The guard in updateSpaceShare now uses this predicate.

Testing

  • New internal/grpc/services/gateway/usershareprovider_test.go:
    • TestMayRemoveLastPermanentManager — a manager grant that gains an expiration is now treated like a manager-role drop (so the guard runs).
    • TestIsSpaceManagerRemaining — documents that expiring and self grants do not keep a space managed.
  • go test ./internal/grpc/services/gateway/ passes.

Downstream

This is the reva-side fix for owncloud/ocis#11205. The oCIS dependency on owncloud/reva/v2 will be bumped to pick it up once this merges.

Setting an expiration on the last permanent manager of a space was allowed,
which left the space without any manager once the grant expired. updateSpaceShare
only ran the "is a permanent manager remaining" check when a grant dropped the
manager role (RemoveGrant=false). It now also runs when a manager grant is given
an expiration, via the new mayRemoveLastPermanentManager predicate, since an
expiring manager is not a permanent manager.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Signed-off-by: David Walter <[email protected]>
@dj4oC
dj4oC force-pushed the fix/space-last-manager-expiration branch from 1280d6c to 2d7d069 Compare June 13, 2026 14:51
@kw-security

kw-security commented Jun 13, 2026 •

Copy link
Copy Markdown

✅ Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
✅ Code Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@dj4oC

dj4oC commented Jun 23, 2026

Copy link
Copy Markdown
Author

@owncloud/ocis-maintainers — friendly nudge: this PR has had no review since it was opened on 2026-06-13 and CI is green. Could someone take a look when you have a moment? Happy to rebase or adjust if anything needs changing.

@2403905
2403905 merged commit 13a8b48 into owncloud:main Jul 6, 2026
25 of 27 checks passed
butonic added a commit to opencloud-eu/reva 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]>
mklos-kw added a commit that referenced this pull request Nov 12, 2026
* fix(gateway): prevent setting an expiration on the last space manager (#631)

Setting an expiration on the last permanent manager of a space was allowed,
which left the space without any manager once the grant expired. updateSpaceShare
only ran the "is a permanent manager remaining" check when a grant dropped the
manager role (RemoveGrant=false). It now also runs when a manager grant is given
an expiration, via the new mayRemoveLastPermanentManager predicate, since an
expiring manager is not a permanent manager.

Signed-off-by: David Walter <[email protected]>
Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>

* fix: [OCISDEV-810] fix the space role and custom role checks (#653)

* fix: [OCISDEV-971] escape oc:tags and lock owner name in PROPFIND responses (#652)

* feat: [OCISDEV-720] fix public link

---------

Signed-off-by: David Walter <[email protected]>
Co-authored-by: David Walter <[email protected]>
Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
Co-authored-by: Roman Perekhod <[email protected]>
Co-authored-by: Firas Frikha <[email protected]>
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