casbinx

package
v0.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 13, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const DBName = "casbin"

Variables

This section is empty.

Functions

func AddPolicy

func AddPolicy(sub, obj, act string) error

AddPolicy 添加权限

func Enable

func Enable(ctx context.Context, cfg Config, dbDao *zorm.DBDao, redisClient redis.UniversalClient)

Enable 开启并初始化casbin

func Enforce

func Enforce(rvals ...any) (bool, error)

Enforce 验证

func InitDB

func InitDB(cfg Config, dbDao *zorm.DBDao) error

InitDB 初始化casbin数据库

func RemoveFilteredPolicy

func RemoveFilteredPolicy(fIdx int, fval ...string) error

RemoveFilteredPolicy 根据条件删除权限 例如: RemoveFilteredPolicy(0, "role") // 根据角色删除 RemoveFilteredPolicy(1, "path") // 根据接口地址删除 RemoveFilteredPolicy(1, "path", "method") // 根据接口地址和请求方式删除 RemoveFilteredPolicy(2, "method") // 根据请求方式删除

Types

type Config

type Config struct {
	CasbinRuleTable string `mapstructure:"casbin-rule-table"`
	RbacRule        string `mapstructure:"rbac-rule"`
}

type RedisCache

type RedisCache struct {
	// contains filtered or unexported fields
}

func NewCache

func NewCache(client redis.UniversalClient) *RedisCache

func (*RedisCache) Clear

func (c *RedisCache) Clear() error

func (*RedisCache) Delete

func (c *RedisCache) Delete(key string) error

func (*RedisCache) Get

func (c *RedisCache) Get(key string) (bool, error)

func (*RedisCache) Set

func (c *RedisCache) Set(key string, value bool, extra ...interface{}) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL