@@ -27,6 +27,7 @@ import (
27
27
"github.com/Masterminds/sprig"
28
28
provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1"
29
29
ctxpkg "github.com/cs3org/reva/pkg/ctx"
30
+ "github.com/cs3org/reva/pkg/errtypes"
30
31
"github.com/cs3org/reva/pkg/storage"
31
32
"github.com/cs3org/reva/pkg/storage/fs/registry"
32
33
"github.com/cs3org/reva/pkg/storage/utils/eosfs"
@@ -39,16 +40,15 @@ func init() {
39
40
}
40
41
41
42
const (
42
- eosProjectsNamespace = "/eos/project"
43
+ eosProjectsNamespace = "/eos/project/ "
43
44
44
45
// We can use a regex for these, but that might have inferior performance
45
- projectSpaceGroupsPrefix = "cernbox-project-"
46
- projectSpaceAdminGroups = "-admins"
46
+ projectSpaceGroupsPrefix = "cernbox-project-"
47
+ projectSpaceAdminGroupsSuffix = "-admins"
47
48
)
48
49
49
50
type wrapper struct {
50
51
storage.FS
51
- config * eosfs.Config
52
52
mountIDTemplate * template.Template
53
53
}
54
54
@@ -90,7 +90,7 @@ func New(m map[string]interface{}) (storage.FS, error) {
90
90
return nil , err
91
91
}
92
92
93
- return & wrapper {FS : eos , config : c , mountIDTemplate : mountIDTemplate }, nil
93
+ return & wrapper {FS : eos , mountIDTemplate : mountIDTemplate }, nil
94
94
}
95
95
96
96
// We need to override the two methods, GetMD and ListFolder to fill the
@@ -142,13 +142,21 @@ func (w *wrapper) getMountID(ctx context.Context, r *provider.ResourceInfo) stri
142
142
}
143
143
144
144
func (w * wrapper ) setProjectSharingPermissions (ctx context.Context , r * provider.ResourceInfo ) error {
145
- if strings .HasPrefix (w .config .Namespace , eosProjectsNamespace ) {
145
+ if strings .HasPrefix (r .Path , eosProjectsNamespace ) {
146
+
147
+ // Extract project name from the path resembling /eos/project/c/cernbox/minutes/..
148
+ path := strings .TrimPrefix (r .Path , eosProjectsNamespace )
149
+ parts := strings .SplitN (path , "/" , 3 )
150
+ if len (parts ) != 3 {
151
+ return errtypes .BadRequest ("eoswrapper: path does not follow the allowed format" )
152
+ }
153
+ adminGroup := projectSpaceGroupsPrefix + parts [1 ] + projectSpaceAdminGroupsSuffix
154
+
146
155
var userHasSharingAccess bool
147
156
user := ctxpkg .ContextMustGetUser (ctx )
148
157
149
158
for _ , g := range user .Groups {
150
- // Check if user is present in the admins groups
151
- if strings .HasPrefix (g , projectSpaceGroupsPrefix ) && strings .HasSuffix (g , projectSpaceAdminGroups ) {
159
+ if g == adminGroup {
152
160
userHasSharingAccess = true
153
161
break
154
162
}
0 commit comments