Repository navigation
feat(decomposedfs): personal space permissions - #963
Conversation
|
|
||
| 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") |
There was a problem hiding this comment.
If we don't exit here the space type is empty. Does that bypass the personal space filter then?
| } | ||
| } | ||
|
|
||
| if restore && !fs.p.SpaceAbility(ctx, spaceID) { |
There was a problem hiding this comment.
This only checks for ReadWriteEnabled, I think we need to check the space type and permission here too, no?
|
|
||
| // mustCheckPersonalNodePermissions is the Drives.ListPersonal counterpart of MustCheckNodePermissions. | ||
| func (fs *Decomposedfs) mustCheckPersonalNodePermissions(ctx context.Context, unrestricted bool) bool { | ||
| if fs.p.ListAllPersonalSpaces(ctx) && unrestricted { |
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
lgtm (besides the changes in utils/decomposedfs which have to be removed)
7994ea1 to
4e08263
Compare
4e08263 to
51dae6b
Compare
64e9a98 to
aa05bf3
Compare
There was a problem hiding this comment.
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.DeleteAllSpacesUseras a user whose role only hasDrives.ListPersonal. The comment explains it, but the name points elsewhere. A dedicated user, as the "update spaces" tests do formanager,editorandviewer, would make it readable without the comment, e.g.personalLister := &userv1beta1.User{Id: &userv1beta1.UserId{OpaqueId: "personal-lister"}}
with
Drives.ListPersonalingrantedPermissions.
None of these block the merge.
b332097 to
49f3ce1
Compare
|
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. |
…has listing permissions
…y to restore space
…o space root and no space type(mirror storageSpaceFromNode similar guard)
… use dedicated test user
49f3ce1 to
4566550
Compare
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
GetMDandUpdateStorageSpacefail 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