feat(permissions): bump reva to related pr, upd acceptance tests affected by permissions change

This commit is contained in:
Alex Ababii committed 2026-11-20 17:24:48 +01:00
1 parent ddea1f00c3
commit ee62e17fa3
7 files changed
+119 -57

No files matched your search

+3
View File
@@ -404,3 +404,6 @@ replace go-micro.dev/v4 => github.com/butonic/go-micro/v4 v4.11.4-0.202609292135
exclude github.com/mattn/go-sqlite3 v2.0.3+incompatible
replace github.com/go-micro/plugins/v4/store/nats-js-kv => github.com/opencloud-eu/go-micro-plugins/v4/store/nats-js-kv v0.0.0-20250512152754-23325793059a
// TEMP: remove once reva#963 (feat/personal_space_permissions) is released and bump reva to the release version
replace github.com/opencloud-eu/reva/v3 => github.com/maki5/reva/v3 v3.0.0-20261117123005-56afac944faf
+2
View File
@@ -642,6 +642,8 @@ github.com/lufia/plan9stats v0.0.0-20260330125221-c963978e514e h1:Q6MvJtQK/iRcRt
github.com/lufia/plan9stats v0.0.0-20260330125221-c963978e514e/go.mod h1:autxFIvghDt3jPTLoqZ9OZ7s9qTGNAWmYCjVFWPX/zg=
github.com/magiconair/properties v1.8.10 h1:s31yESBquKXCV9a/ScB3ESkOjUYYv+X0rg8SYxI99mE=
github.com/magiconair/properties v1.8.10/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0=
github.com/maki5/reva/v3 v3.0.0-20261117123005-56afac944faf h1:4cTvTHMbTxJf99AKyMms1JBesygi1yv7sxEknWZAnDE=
github.com/maki5/reva/v3 v3.0.0-20261117123005-56afac944faf/go.mod h1:GYVaPfxKgmER65YvpN0uwYL8QSXnwXbR4Qr3iwsYlPU=
github.com/maruel/natural v1.1.1 h1:Hja7XhhmvEFhcByqDoHz9QZbkWey+COd9xWfCfn1ioo=
github.com/maruel/natural v1.1.1/go.mod h1:v+Rfd79xlw1AgVBjbO0BEQmptqb5HvL/k9GRHB7ZKEg=
github.com/mattermost/xml-roundtrip-validator v0.1.0 h1:RXbVD2UAl7A7nOTR4u7E3ILa4IbtvKBHw64LDsmu9hU=
@@ -49,34 +49,10 @@ Feature: Space management
And the json response should not contain a space with name "Alice Hansen"
Scenario: space admin user can see another personal spaces
Scenario: space admin user cannot see another personal spaces
When user "Brian" lists all spaces via the Graph API with query "$filter=driveType eq 'personal'"
Then the HTTP status code should be "200"
And the JSON response should contain space called "Alice Hansen" and match
"""
{
"type": "object",
"required": [
"driveType",
"name",
"id"
],
"properties": {
"name": {
"type": "string",
"enum": ["Alice Hansen"]
},
"driveType": {
"type": "string",
"enum": ["personal"]
},
"id": {
"type": "string",
"enum": ["%space_id%"]
}
}
}
"""
And the json response should not contain a space with name "Alice Hansen"
And the json response should not contain a space with name "Project"
@@ -155,10 +131,8 @@ Feature: Space management
Then the HTTP status code should be "<code>"
Examples:
| user | code |
# Brian is Space Admin and can currently list all Personal Spaces, so he
# gets a 403 instead of a 404 here. This might change in the future see:
# https://github.com/opencloud-eu/opencloud/issues/2979
| Brian | 403 |
# The Space Admin role has no permission to list personal spaces, so Brian gets 404 like Carol
| Brian | 404 |
| Carol | 404 |
@@ -376,7 +376,7 @@ func (fs *Decomposedfs) GetQuota(ctx context.Context, ref *provider.Reference) (
switch {
case err != nil:
return 0, 0, 0, err
case !rp.GetQuota && !fs.p.ListAllSpaces(ctx):
case !rp.GetQuota && !fs.canListAllSpaces(ctx, n):
f, _ := storagespace.FormatReference(ref)
if rp.Stat {
return 0, 0, 0, errtypes.PermissionDenied(f)
@@ -84,8 +84,13 @@ func (p Permissions) SetSpaceQuota(ctx context.Context, spaceid string, spaceTyp
}
// ManageSpaceProperties returns true when the user is allowed to change space properties (name/subtitle)
func (p Permissions) ManageSpaceProperties(ctx context.Context, spaceid string) bool {
return p.checkPermission(ctx, "Drives.ReadWrite", spaceRef(spaceid))
func (p Permissions) ManageSpaceProperties(ctx context.Context, spaceid string, spaceType string) bool {
switch spaceType {
case _spaceTypePersonal:
return p.checkPermission(ctx, "Drives.ReadWritePersonal", spaceRef(spaceid))
default:
return p.checkPermission(ctx, "Drives.ReadWrite", spaceRef(spaceid))
}
}
// SpaceAbility returns true when the user is allowed to enable/disable the space
@@ -93,11 +98,26 @@ func (p Permissions) SpaceAbility(ctx context.Context, spaceid string) bool {
return p.checkPermission(ctx, "Drives.ReadWriteEnabled", spaceRef(spaceid))
}
// ListAllSpaces returns true when the user is allowed to list all spaces
// RestoreSpace returns true when the user is allowed to restore a disabled space
func (p Permissions) RestoreSpace(ctx context.Context, spaceid string, spaceType string) bool {
switch spaceType {
case _spaceTypePersonal:
return p.DeleteAllHomeSpaces(ctx)
default:
return p.SpaceAbility(ctx, spaceid)
}
}
// ListAllSpaces returns true when the user is allowed to list all project spaces
func (p Permissions) ListAllSpaces(ctx context.Context) bool {
return p.checkPermission(ctx, "Drives.List", nil)
}
// ListAllPersonalSpaces returns true when the user is allowed to list all personal spaces
func (p Permissions) ListAllPersonalSpaces(ctx context.Context) bool {
return p.checkPermission(ctx, "Drives.ListPersonal", nil)
}
// ListSpacesOfUser returns true when the user is allowed to list the spaces of the given user
func (p Permissions) ListSpacesOfUser(ctx context.Context, userid *userv1beta1.UserId) bool {
switch {
@@ -107,7 +127,7 @@ func (p Permissions) ListSpacesOfUser(ctx context.Context, userid *userv1beta1.U
case utils.UserIDEqual(ctxpkg.ContextMustGetUser(ctx).GetId(), userid):
return true
default:
return p.ListAllSpaces(ctx)
return p.ListAllSpaces(ctx) || p.ListAllPersonalSpaces(ctx)
}
}
@@ -311,7 +311,8 @@ func (fs *Decomposedfs) ListStorageSpaces(ctx context.Context, filter []*provide
return nil, errtypes.PermissionDenied(fmt.Sprintf("user %s is not allowed to list spaces of other users", authenticatedUserID))
}
checkNodePermissions := fs.MustCheckNodePermissions(ctx, unrestricted)
checkProjectNodePermissions := fs.MustCheckNodePermissions(ctx, unrestricted)
checkPersonalNodePermissions := fs.mustCheckPersonalNodePermissions(ctx, unrestricted)
spaces := []*provider.StorageSpace{}
// build the glob path, eg.
@@ -330,7 +331,7 @@ func (fs *Decomposedfs) ListStorageSpaces(ctx context.Context, filter []*provide
// return empty list
return spaces, nil
}
space, err := fs.StorageSpaceFromNode(ctx, n, checkNodePermissions)
space, err := fs.storageSpaceFromNode(ctx, n, checkProjectNodePermissions, checkPersonalNodePermissions)
if err != nil {
return nil, err
}
@@ -484,7 +485,7 @@ func (fs *Decomposedfs) ListStorageSpaces(ctx context.Context, filter []*provide
continue
}
space, err := fs.StorageSpaceFromNode(ctx, n, checkNodePermissions)
space, err := fs.storageSpaceFromNode(ctx, n, checkProjectNodePermissions, checkPersonalNodePermissions)
if err != nil {
switch err.(type) {
case errtypes.IsPermissionDenied:
@@ -549,7 +550,7 @@ func (fs *Decomposedfs) ListStorageSpaces(ctx context.Context, filter []*provide
return nil, err
}
if n.Exists {
space, err := fs.StorageSpaceFromNode(ctx, n, checkNodePermissions)
space, err := fs.storageSpaceFromNode(ctx, n, checkProjectNodePermissions, checkPersonalNodePermissions)
if err != nil {
return nil, err
}
@@ -588,17 +589,45 @@ func (fs *Decomposedfs) UserIDToUserAndGroups(ctx context.Context, userid *userv
// MustCheckNodePermissions checks if permission checks are needed to be performed when user requests spaces
func (fs *Decomposedfs) MustCheckNodePermissions(ctx context.Context, unrestricted bool) bool {
// canListAllSpaces indicates if the user has the permission from the global user role
canListAllSpaces := fs.p.ListAllSpaces(ctx)
// and requests all spaces
canListAllSpaces := unrestricted && fs.p.ListAllSpaces(ctx)
// unrestricted is the param which indicates if the user wants to list all spaces or only the spaces he is part of
// if a user lists all spaces unrestricted and doesn't have the permissions from the role, we need to check
// the nodePermissions and this will return a spaces list where the user has access to
// we can only skip the NodePermissions check if both values are true
if canListAllSpaces && unrestricted {
if canListAllSpaces {
return false
}
return true
}
// canListAllSpaces returns true when the user is allowed to list all spaces of the given node's type
func (fs *Decomposedfs) canListAllSpaces(ctx context.Context, n *node.Node) bool {
if n.SpaceRoot == nil {
return false
}
spaceType, err := n.SpaceRoot.XattrString(ctx, prefixes.SpaceTypeAttr)
if err != nil {
return false
}
if spaceType == _spaceTypePersonal {
return fs.p.ListAllPersonalSpaces(ctx)
}
return fs.p.ListAllSpaces(ctx)
}
// mustCheckPersonalNodePermissions is the Drives.ListPersonal counterpart of MustCheckNodePermissions.
func (fs *Decomposedfs) mustCheckPersonalNodePermissions(ctx context.Context, unrestricted bool) bool {
if unrestricted && fs.p.ListAllPersonalSpaces(ctx) {
return false
}
return true
}
// UpdateStorageSpace updates a storage space
func (fs *Decomposedfs) UpdateStorageSpace(ctx context.Context, req *provider.UpdateStorageSpaceRequest) (*provider.UpdateStorageSpaceResponse, error) {
var restore bool
@@ -693,16 +722,40 @@ func (fs *Decomposedfs) UpdateStorageSpace(ctx context.Context, req *provider.Up
k = append(k, prefixes.SpaceReadmeAttr, prefixes.SpaceAliasAttr, prefixes.SpaceImageAttr)
}
if mapHasKey(metadata, k...) && !fs.p.ManageSpaceProperties(ctx, spaceID) {
return &provider.UpdateStorageSpaceResponse{
Status: &v1beta11.Status{Code: v1beta11.Code_CODE_PERMISSION_DENIED},
}, nil
if mapHasKey(metadata, k...) {
typ, err := spaceNode.SpaceRoot.Xattr(ctx, prefixes.SpaceTypeAttr)
if err != nil {
return &provider.UpdateStorageSpaceResponse{
Status: &v1beta11.Status{
Code: v1beta11.Code_CODE_INTERNAL,
Message: "space has no type",
},
}, nil
}
if !fs.p.ManageSpaceProperties(ctx, spaceID, string(typ)) {
return &provider.UpdateStorageSpaceResponse{
Status: &v1beta11.Status{Code: v1beta11.Code_CODE_PERMISSION_DENIED},
}, nil
}
}
if restore && !fs.p.SpaceAbility(ctx, spaceID) {
return &provider.UpdateStorageSpaceResponse{
Status: &v1beta11.Status{Code: v1beta11.Code_CODE_NOT_FOUND},
}, nil
if restore {
typ, 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
}
if !fs.p.RestoreSpace(ctx, spaceID, typ) {
return &provider.UpdateStorageSpaceResponse{
Status: &v1beta11.Status{Code: v1beta11.Code_CODE_NOT_FOUND},
}, nil
}
}
}
@@ -1000,7 +1053,22 @@ func (fs *Decomposedfs) linkStorageSpaceType(ctx context.Context, spaceType, spa
}
func (fs *Decomposedfs) StorageSpaceFromNode(ctx context.Context, n *node.Node, checkPermissions bool) (*provider.StorageSpace, error) {
return fs.storageSpaceFromNode(ctx, n, checkPermissions, checkPermissions)
}
func (fs *Decomposedfs) storageSpaceFromNode(ctx context.Context, n *node.Node, checkProjectNodePermissions, checkPersonalNodePermissions bool) (*provider.StorageSpace, error) {
user := ctxpkg.ContextMustGetUser(ctx)
spaceType, err := n.SpaceRoot.XattrString(ctx, prefixes.SpaceTypeAttr)
if err != nil {
return nil, errtypes.InternalError(fmt.Sprintf("space %s does not have a type attribute", n.GetID()))
}
checkPermissions := checkProjectNodePermissions
if spaceType == _spaceTypePersonal {
checkPermissions = checkPersonalNodePermissions
}
if checkPermissions {
rp, err := fs.p.AssemblePermissions(ctx, n)
switch {
@@ -1020,7 +1088,6 @@ func (fs *Decomposedfs) StorageSpaceFromNode(ctx context.Context, n *node.Node,
sublog := appctx.GetLogger(ctx).With().Str("spaceid", n.GetSpaceID()).Logger()
var err error
// TODO apply more filters
var sname string
if sname, err = n.SpaceRoot.XattrString(ctx, prefixes.SpaceNameAttr); err != nil {
@@ -1145,16 +1212,11 @@ func (fs *Decomposedfs) StorageSpaceFromNode(ctx context.Context, n *node.Node,
SpaceId: n.SpaceRoot.GetSpaceID(),
OpaqueId: n.SpaceRoot.GetID(),
},
Name: sname,
// SpaceType is read from xattr below
Name: sname,
SpaceType: spaceType,
// Mtime is set either as node.tmtime or as fi.mtime below
}
space.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")
}
if n.SpaceRoot.IsDisabled(ctx) {
space.Opaque = utils.AppendPlainToOpaque(space.Opaque, "trashed", "trashed")
}
+1
View File
@@ -2693,3 +2693,4 @@ stash.kopano.io/kgol/rndm
# github.com/unrolled/secure => github.com/opencloud-eu/secure v0.0.0-20260312082735-b6f5cb2244e4
# go-micro.dev/v4 => github.com/butonic/go-micro/v4 v4.11.4-0.20260929213538-cd412c159a26
# github.com/go-micro/plugins/v4/store/nats-js-kv => github.com/opencloud-eu/go-micro-plugins/v4/store/nats-js-kv v0.0.0-20250512152754-23325793059a
# github.com/opencloud-eu/reva/v3 => github.com/maki5/reva/v3 v3.0.0-20261117123005-56afac944faf