forked from tangled.org/core
Monorepo for Tangled

rbac: use standard casbin keymatcher

path.Match does not work as expected; but our ACLs currently do not make
use of these anyway. glob/wildcard matching can be implemented in the
future.

Changed files
+1 -17
rbac
+1 -17
rbac/rbac.go
··· 3 3 import ( 4 4 "database/sql" 5 5 "fmt" 6 - "path" 7 6 "strings" 8 7 9 8 adapter "github.com/Blank-Xu/sql-adapter" ··· 26 25 e = some(where (p.eft == allow)) 27 26 28 27 [matchers] 29 - m = r.act == p.act && r.dom == p.dom && keyMatch2(r.obj, p.obj) && g(r.sub, p.sub, r.dom) 28 + m = r.act == p.act && r.dom == p.dom && r.obj == p.obj && g(r.sub, p.sub, r.dom) 30 29 ` 31 30 ) 32 31 ··· 34 33 E *casbin.Enforcer 35 34 } 36 35 37 - func keyMatch2(key1 string, key2 string) bool { 38 - matched, _ := path.Match(key2, key1) 39 - return matched 40 - } 41 - 42 36 func NewEnforcer(path string) (*Enforcer, error) { 43 37 m, err := model.NewModelFromString(Model) 44 38 if err != nil { ··· 61 55 } 62 56 63 57 e.EnableAutoSave(false) 64 - 65 - e.AddFunction("keyMatch2", keyMatch2Func) 66 58 67 59 return &Enforcer{e}, nil 68 60 } ··· 209 201 } 210 202 211 203 return permissions 212 - } 213 - 214 - // keyMatch2Func is a wrapper for keyMatch2 to make it compatible with Casbin 215 - func keyMatch2Func(args ...interface{}) (interface{}, error) { 216 - name1 := args[0].(string) 217 - name2 := args[1].(string) 218 - 219 - return keyMatch2(name1, name2), nil 220 204 } 221 205 222 206 func checkRepoFormat(repo string) error {