Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ require (
github.com/coreos/go-oidc/v3 v3.20.0
github.com/creasty/defaults v1.8.0
github.com/cs3org/cato v0.0.0-20200828125504-e418fc54dd5e
github.com/cs3org/go-cs3apis v0.0.0-20260812114726-73172748ac6b
github.com/cs3org/go-cs3apis v0.0.0-20260903141024-c92f9566c2e1
github.com/dgraph-io/ristretto v0.2.0
github.com/dolthub/go-mysql-server v0.14.0
github.com/glpatcern/go-mime v0.0.0-20221026162842-2a8d71ad17a9
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -896,6 +896,8 @@ github.com/cs3org/cato v0.0.0-20200828125504-e418fc54dd5e h1:tqSPWQeueWTKnJVMJff
github.com/cs3org/cato v0.0.0-20200828125504-e418fc54dd5e/go.mod h1:XJEZ3/EQuI3BXTp/6DUzFr850vlxq11I6satRtz0YQ4=
github.com/cs3org/go-cs3apis v0.0.0-20260812114726-73172748ac6b h1:dxDXmPpNjyEFYktWjpblcSz64xqUt+twXGth7Ke8qV0=
github.com/cs3org/go-cs3apis v0.0.0-20260812114726-73172748ac6b/go.mod h1:DedpcqXl193qF/08Y04IO0PpxyyMu8+GrkD6kWK2MEQ=
github.com/cs3org/go-cs3apis v0.0.0-20260903141024-c92f9566c2e1 h1:GEbTSrtJC2wqoUQfL1Up55RztD2a6G3X7aK4LTu3VmA=
github.com/cs3org/go-cs3apis v0.0.0-20260903141024-c92f9566c2e1/go.mod h1:DedpcqXl193qF/08Y04IO0PpxyyMu8+GrkD6kWK2MEQ=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/denisenkom/go-mssqldb v0.10.0 h1:QykgLZBorFE95+gO3u9esLd0BmbvpWp0/waNNZfHBM8=
Expand Down
36 changes: 34 additions & 2 deletions internal/grpc/services/spacesregistry/spacesregistry.go
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,21 @@ func (s *service) userSpace(ctx context.Context, user *userpb.User) (*provider.S
QuotaMaxBytes: quota.TotalBytes,
RemainingBytes: quota.TotalBytes - quota.UsedBytes,
},
PermissionSet: permissions.NewManagerRole().CS3ResourcePermissions(),
Roles: []*provider.SpaceRole{
{
RoleName: "owner",
PermissionSet: permissions.NewManagerRole().CS3ResourcePermissions(),
Recipients: []*provider.Grantee{
{
Type: provider.GranteeType_GRANTEE_TYPE_USER,
Id: &provider.Grantee_UserId{
UserId: user.Id,
},
},
},
},
},
//PermissionSet: permissions.NewManagerRole().CS3ResourcePermissions(),
}, nil
}

Expand All @@ -445,6 +459,11 @@ func (s *service) getAllPublicSpaces(ctx context.Context) ([]*provider.StorageSp
return nil, err
}

user, ok := appctx.ContextGetUser(ctx)
if !ok {
return nil, errtypes.UserRequired("Must have a user to list public spaces")
}

publicSpaces := make([]*provider.StorageSpace, 0)
for spaceName, content := range s.c.PublicSpaces {
path, ok := content["path"]
Expand Down Expand Up @@ -488,7 +507,20 @@ func (s *service) getAllPublicSpaces(ctx context.Context) ([]*provider.StorageSp
QuotaMaxBytes: uint64(math.Pow10(18)),
RemainingBytes: uint64(math.Pow10(18)) - resourceInfo.Size,
},
PermissionSet: resourceInfo.PermissionSet,
Roles: []*provider.SpaceRole{
{
RoleName: "user",
PermissionSet: resourceInfo.PermissionSet,
Recipients: []*provider.Grantee{
{
Type: provider.GranteeType_GRANTEE_TYPE_USER,
Id: &provider.Grantee_UserId{
UserId: user.Id,
},
},
},
},
},
}

if description, ok := content["description"]; ok {
Expand Down
48 changes: 44 additions & 4 deletions pkg/projects/manager/sql/sql.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"time"

"github.com/ReneKroon/ttlcache/v2"
groupv1beta1 "github.com/cs3org/go-cs3apis/cs3/identity/group/v1beta1"
userpb "github.com/cs3org/go-cs3apis/cs3/identity/user/v1beta1"
rpcv1beta1 "github.com/cs3org/go-cs3apis/cs3/rpc/v1beta1"
provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1"
Expand Down Expand Up @@ -387,10 +388,49 @@ func projectToStorageSpace(p *Project, perms *provider.ResourcePermissions) *pro
Path: p.Path,
PermissionSet: perms,
},
Description: p.Description,
ThumbnailId: p.ThumbnailPath,
ReadmeId: p.ReadmePath,
PermissionSet: perms,
Description: p.Description,
ThumbnailId: p.ThumbnailPath,
ReadmeId: p.ReadmePath,
Roles: []*provider.SpaceRole{{
RoleName: "reader",
PermissionSet: permissions.NewViewerRole().CS3ResourcePermissions(),
Recipients: []*provider.Grantee{
{
Type: provider.GranteeType_GRANTEE_TYPE_GROUP,
Id: &provider.Grantee_GroupId{
GroupId: &groupv1beta1.GroupId{
OpaqueId: p.Readers,
},
},
},
},
}, {
RoleName: "writer",
PermissionSet: permissions.NewEditorRole().CS3ResourcePermissions(),
Recipients: []*provider.Grantee{
{
Type: provider.GranteeType_GRANTEE_TYPE_GROUP,
Id: &provider.Grantee_GroupId{
GroupId: &groupv1beta1.GroupId{
OpaqueId: p.Writers,
},
},
},
},
}, {
RoleName: "admin",
PermissionSet: permissions.NewManagerRole().CS3ResourcePermissions(),
Recipients: []*provider.Grantee{
{
Type: provider.GranteeType_GRANTEE_TYPE_GROUP,
Id: &provider.Grantee_GroupId{
GroupId: &groupv1beta1.GroupId{
OpaqueId: p.Admins,
},
},
},
},
}},
}
}

Expand Down
53 changes: 48 additions & 5 deletions pkg/projects/manager/sql/sql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"reflect"
"testing"

groupv1beta1 "github.com/cs3org/go-cs3apis/cs3/identity/group/v1beta1"
userpb "github.com/cs3org/go-cs3apis/cs3/identity/user/v1beta1"
provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1"
"github.com/cs3org/reva/v3/pkg/appctx"
Expand Down Expand Up @@ -57,6 +58,48 @@ func TestListProjects(t *testing.T) {

spaceID := spaces.EncodeSpaceID("/path/to/project")

// Every project in the test cases below uses these e-groups
roles := []*provider.SpaceRole{{
RoleName: "reader",
PermissionSet: permissions.NewViewerRole().CS3ResourcePermissions(),
Recipients: []*provider.Grantee{
{
Type: provider.GranteeType_GRANTEE_TYPE_GROUP,
Id: &provider.Grantee_GroupId{
GroupId: &groupv1beta1.GroupId{
OpaqueId: "project-readers",
},
},
},
},
}, {
RoleName: "writer",
PermissionSet: permissions.NewEditorRole().CS3ResourcePermissions(),
Recipients: []*provider.Grantee{
{
Type: provider.GranteeType_GRANTEE_TYPE_GROUP,
Id: &provider.Grantee_GroupId{
GroupId: &groupv1beta1.GroupId{
OpaqueId: "project-writers",
},
},
},
},
}, {
RoleName: "admin",
PermissionSet: permissions.NewManagerRole().CS3ResourcePermissions(),
Recipients: []*provider.Grantee{
{
Type: provider.GranteeType_GRANTEE_TYPE_GROUP,
Id: &provider.Grantee_GroupId{
GroupId: &groupv1beta1.GroupId{
OpaqueId: "project-admins",
},
},
},
},
}}

tests := []struct {
description string
projects []*Project
Expand Down Expand Up @@ -100,7 +143,7 @@ func TestListProjects(t *testing.T) {
Path: "/path/to/project",
PermissionSet: permissions.NewManagerRole().CS3ResourcePermissions(),
},
PermissionSet: permissions.NewManagerRole().CS3ResourcePermissions(),
Roles: roles,
},
},
},
Expand Down Expand Up @@ -135,7 +178,7 @@ func TestListProjects(t *testing.T) {
Path: "/path/to/project",
PermissionSet: permissions.NewViewerRole().CS3ResourcePermissions(),
},
PermissionSet: permissions.NewViewerRole().CS3ResourcePermissions(),
Roles: roles,
},
},
},
Expand Down Expand Up @@ -170,7 +213,7 @@ func TestListProjects(t *testing.T) {
Path: "/path/to/project",
PermissionSet: permissions.NewEditorRole().CS3ResourcePermissions(),
},
PermissionSet: permissions.NewEditorRole().CS3ResourcePermissions(),
Roles: roles,
},
},
},
Expand Down Expand Up @@ -205,7 +248,7 @@ func TestListProjects(t *testing.T) {
Path: "/path/to/project",
PermissionSet: permissions.NewManagerRole().CS3ResourcePermissions(),
},
PermissionSet: permissions.NewManagerRole().CS3ResourcePermissions(),
Roles: roles,
},
},
},
Expand Down Expand Up @@ -240,7 +283,7 @@ func TestListProjects(t *testing.T) {
Path: "/path/to/project",
PermissionSet: permissions.NewManagerRole().CS3ResourcePermissions(),
},
PermissionSet: permissions.NewManagerRole().CS3ResourcePermissions(),
Roles: roles,
},
},
},
Expand Down
2 changes: 2 additions & 0 deletions pkg/reconciliation/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.json
!testdata/*.json
Loading
Loading