disabler

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 11, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultModelText 默认 casbin 模型文本
	DefaultModelText = `` /* 232-byte string literal not displayed */

)

Variables

This section is empty.

Functions

This section is empty.

Types

type Adapter

type Adapter struct {
	Routes []string
}

Adapter 决策规则适配器

func NewAdapter

func NewAdapter(routes []string) *Adapter

NewAdapter 新建决策规则适配器

func (*Adapter) AddPolicy

func (a *Adapter) AddPolicy(sec, ptype string, rule []string) error

AddPolicy 添加决策规则

func (*Adapter) LoadPolicy

func (a *Adapter) LoadPolicy(m model.Model) error

LoadPolicy 加载决策规则

func (*Adapter) RemoveFilteredPolicy

func (a *Adapter) RemoveFilteredPolicy(sec, ptype string, fieldIndex int, fieldValues ...string) error

RemoveFilteredPolicy 移除筛选后的决策规则

func (*Adapter) RemovePolicy

func (a *Adapter) RemovePolicy(sec, ptype string, rule []string) error

RemovePolicy 移除决策规则

func (*Adapter) SavePolicy

func (a *Adapter) SavePolicy(m model.Model) error

SavePolicy 保存决策规则

type Config

type Config struct {
	DisabledAPIs []string `json:",optional"` // API 禁用列表
	DisabledRPCs []string `json:",optional"` // RPC 禁用列表
}

Config 功能禁用器配置

type FuncDisabler

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

FuncDisabler 功能禁用器

func MustNewFuncDisabler

func MustNewFuncDisabler(c Config) *FuncDisabler

MustNewFuncDisabler 新建功能禁用器

func NewFuncDisabler

func NewFuncDisabler(c Config) (*FuncDisabler, error)

NewFuncDisabler 新建功能禁用器

func (*FuncDisabler) AllowAPI

func (fd *FuncDisabler) AllowAPI(method, api string) bool

AllowAPI 是否允许放行该 API 请求

func (*FuncDisabler) AllowRPC

func (fd *FuncDisabler) AllowRPC(rpc string) bool

AllowRPC 是否允许放行该 RPC 请求

Jump to

Keyboard shortcuts

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