Skip to content

feat(decomposedfs): personal space permissions - #963

Merged
maki5 merged 9 commits into
opencloud-eu:mainfrom
maki5:feat/personal_space_permissions
Nov 20, 2026
Merged

maki5 merged 9 commits into
opencloud-eu:mainfrom
maki5:feat/personal_space_permissions

Conversation

@maki5

@maki5 maki5 commented Nov 2, 2026 •

Copy link
Copy Markdown
  • Drives.List and Drives.ReadWrite now only apply to project spaces.

  • Personal spaces use the new Drives.ListPersonal and Drives.ReadWritePersonal
    permissions.

  • Listing, space properties, quota and user space lookups select the
    permission matching the space type.

    based on @pbleser-oc comment
    2. A missing type now also fails a Stat. Since storageSpaceFromNode returns an error for a space root without a type, GetMD with the space field mask now fails with InternalError too, where it used to return the space with an empty type. Only CreateStorageSpace writes the attribute, so this should only hit broken data. If that's intended, maybe a sentence in the description, so nobody is surprised.

a space root without a type attribute now makes GetMD and UpdateStorageSpace fail with InternalError, instead of returning the space with an empty type. This only affects broken data, since CreateStorageSpace always writes the attribute.

refs: opencloud-eu/opencloud#2979

Comment thread pkg/storage/pkg/decomposedfs/spaces.go Outdated

spaceType, err := n.SpaceRoot.XattrString(ctx, prefixes.SpaceTypeAttr)
if err != nil {
appctx.GetLogger(ctx).Debug().Err(err).Msg("space does not have a type attribute")

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.

If we don't exit here the space type is empty. Does that bypass the personal space filter then?

Comment thread pkg/storage/pkg/decomposedfs/spaces.go Outdated
}
}

if restore && !fs.p.SpaceAbility(ctx, spaceID) {

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.

This only checks for ReadWriteEnabled, I think we need to check the space type and permission here too, no?

Comment thread pkg/storage/pkg/decomposedfs/spaces.go Outdated

// mustCheckPersonalNodePermissions is the Drives.ListPersonal counterpart of MustCheckNodePermissions.
func (fs *Decomposedfs) mustCheckPersonalNodePermissions(ctx context.Context, unrestricted bool) bool {
if fs.p.ListAllPersonalSpaces(ctx) && unrestricted {

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.

An optimization found by Claude is to check unrestricted first which spares a superfluous call to the permissions service for every /me/drives call.

@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 (besides the changes in utils/decomposedfs which have to be removed)

@maki5
maki5 force-pushed the feat/personal_space_permissions branch from 7994ea1 to 4e08263 Compare November 5, 2026 10:50
@maki5
maki5 force-pushed the feat/personal_space_permissions branch from 4e08263 to 51dae6b Compare November 6, 2026 14:38
@maki5
maki5 force-pushed the feat/personal_space_permissions branch 2 times, most recently from 64e9a98 to aa05bf3 Compare November 17, 2026 12:11

@pbleser-oc pbleser-oc 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.

Looks good to me. All three earlier points are addressed, and I checked that the new tests fail without the change (all 9 negative cases). A few optional suggestions:

1. Read the space type once in UpdateStorageSpace. It's now read in up to three places, with two different helpers (Xattr + string() for the properties and the quota, XattrString for the restore). How about reading it once, right after the spaceNode.Exists check, and using it in all three:

spaceType, err := spaceNode.SpaceRoot.XattrString(ctx, prefixes.SpaceTypeAttr)
if err != nil {
	return &provider.UpdateStorageSpaceResponse{
		Status: &v1beta11.Status{Code: v1beta11.Code_CODE_INTERNAL, Message: "space has no type"},
	}, nil
}

and then fs.p.ManageSpaceProperties(ctx, spaceID, spaceType), fs.p.RestoreSpace(ctx, spaceID, spaceType) and fs.p.SetSpaceQuota(ctx, spaceID, spaceType). The only difference: an update of a space without a type would then fail even when it doesn't depend on the type, which matches what the listing now does.

2. A missing type now also fails a Stat. Since storageSpaceFromNode returns an error for a space root without a type, GetMD with the space field mask now fails with InternalError too, where it used to return the space with an empty type. Only CreateStorageSpace writes the attribute, so this should only hit broken data. If that's intended, maybe a sentence in the description, so nobody is surprised.

3. Two naming nitpicks in the tests:

  • "Owner can change the name of his personal space": please use "their personal space" instead.

  • The spec "only lists the personal spaces of another user with Drives.ListPersonal" uses env.DeleteAllSpacesUser as a user whose role only has Drives.ListPersonal. The comment explains it, but the name points elsewhere. A dedicated user, as the "update spaces" tests do for manager, editor and viewer, would make it readable without the comment, e.g.

    personalLister := &userv1beta1.User{Id: &userv1beta1.UserId{OpaqueId: "personal-lister"}}

    with Drives.ListPersonal in grantedPermissions.

None of these block the merge.

@pbleser-oc

Copy link
Copy Markdown
Member

The failing API tests aren't caused by this PR: since this afternoon, the test dependencies need PHP 8.3, and the old test image has 8.2, so Behat doesn't start at all ("Your Composer dependencies require a PHP version >= 8.3.0"). #1038 fixed that on main by switching to the PHP 8.4 image. Could you rebase onto main? The pipeline files come from the PR branch, so a restart alone won't pick up the fix.

@maki5
maki5 force-pushed the feat/personal_space_permissions branch from 49f3ce1 to 4566550 Compare November 20, 2026 15:38
@maki5
maki5 merged commit 20c6e78 into opencloud-eu:main Nov 20, 2026
19 checks passed
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.

4 participants