Skip to content

kotlin2018/adapter

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Installation

go get github.com/kotlin2018/adapter

Usage example

package mian

import (
	"github.com/casbin/casbin/v2"
	"github.com/gogf/gf/frame/g"
	"github.com/kotlin2018/adapter"
)

func main() {
	opts := &adapter.Adapter{
		DriverName: "mysql",
		LinkInfo:   "root:root@tcp(127.0.0.1:3306)/casbin",
		TableName:  "casbin_rule",
	}

	c := &adapter.CasBinModel{
		BaseAdapter: opts,
		ModelPath:   "examples/rbac_model.conf",
	}
	// 添加权限
	c.AuthorityId = "100"
	c.Path = "v1/user"
	c.Method = "POST"
	c.AddCasBin()
	
	// 清除匹配的权限
	c.ClearCasBin()
	
	// 更新casBin权限
	c.AuthorityId = "101"
	c.ReqPolicies = []adapter.CasBinInfo{}
	c.UpdateCasBin()
	
	// 获取权限列表
	c.GetCasBinList()
	
}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages