mirror of
https://github.com/mindoc-org/mindoc.git
synced 2026-02-27 17:03:57 +08:00
32 lines
621 B
Go
32 lines
621 B
Go
package acl
|
|
|
|
import (
|
|
"sync"
|
|
"fmt"
|
|
)
|
|
|
|
var AclList = &sync.Map{}
|
|
|
|
func AddMemberPermission(account string,resource Resource) {
|
|
key := account + "!" + resource.Code
|
|
|
|
AclList.Store(key,resource)
|
|
}
|
|
|
|
//判断指定的资源是否可以访问
|
|
func IsAllow(account ,controllerName,actionName,methodName string) bool {
|
|
|
|
key := fmt.Sprintf("%s!%s!%s!%s",account,controllerName,actionName,methodName)
|
|
fmt.Println(key)
|
|
if _,ok := AclList.Load(key);ok {
|
|
return true
|
|
}
|
|
key = fmt.Sprintf("%s!%s!%s!*",account,controllerName,actionName)
|
|
fmt.Println(key)
|
|
if _,ok := AclList.Load(key);ok {
|
|
return true
|
|
}
|
|
|
|
return false
|
|
}
|