github.com/cs3org/reva/v2@v2.27.7/pkg/permission/manager/demo/demo.go (about) 1 // Copyright 2021 CERN 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 // 15 // In applying this license, CERN does not waive the privileges and immunities 16 // granted to it by virtue of its status as an Intergovernmental Organization 17 // or submit itself to any jurisdiction. 18 19 package demo 20 21 import ( 22 provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1" 23 "github.com/cs3org/reva/v2/pkg/permission" 24 "github.com/cs3org/reva/v2/pkg/permission/manager/registry" 25 ) 26 27 func init() { 28 registry.Register("demo", New) 29 } 30 31 // New returns a new demo permission manager 32 func New(c map[string]interface{}) (permission.Manager, error) { 33 return manager{}, nil 34 } 35 36 type manager struct { 37 } 38 39 func (m manager) CheckPermission(perm string, subject string, ref *provider.Reference) bool { 40 switch perm { 41 case permission.CreateSpace: 42 // TODO Users can only create their own personal space 43 // TODO guest accounts cannot create spaces 44 return true 45 case permission.WritePublicLink: 46 return true 47 case permission.ListAllSpaces: 48 // TODO introduce an admin role to allow listing all spaces 49 return false 50 case permission.WriteShare: 51 // TODO guest accounts cannot share 52 return true 53 case permission.ListFavorites: 54 // TODO guest accounts cannot list favorites 55 return true 56 case permission.WriteFavorites: 57 // TODO guest accounts cannot write favorites 58 return true 59 default: 60 // We can currently return false all the time. 61 // Once we beginn testing roles we need to somehow check the roles of the users here 62 return false 63 } 64 }