golang rbac框架

https://github.com/mikespook/gorbac/tree/v1.0

 github上新的版本是开发板,得用这里的老版

 

demo

package main

import (
    "gopkg.in/mikespook/gorbac.v1"
    "fmt"
)

func main()  {
    permissions := []string{"admin","guest","normal"}

    rbac := gorbac.New()
    rbac.Add("rico",permissions[1:],[]string{})

    IsGranted := rbac.IsGranted("rico","guest",nil)


    fmt.Println("grant is ", IsGranted)
    fmt.Println("dump is ", rbac.Dump())

    fmt.Println("permissions are ",rbac.Get("rico").Permissions())
}

 

你可能感兴趣的:(golang rbac框架)