hippo

package
v0.0.0-...-84fae08 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2020 License: MIT Imports: 6 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthCollection

type AuthCollection struct {
	Table string
	// contains filtered or unexported fields
}

权限数据集合

func (*AuthCollection) AddAuth

func (this *AuthCollection) AddAuth(r *AuthRow)

func (*AuthCollection) AddVeto

func (this *AuthCollection) AddVeto(r *AuthRow)

func (*AuthCollection) HasPermition

func (this *AuthCollection) HasPermition(parameters map[string]interface{}) bool

type AuthColumn

type AuthColumn struct {
	Field    *AuthField //对应的字段
	Type     ValueType  //值类型
	Value    string     //取值
	Negation bool       //取反
}

权限列取值

func (*AuthColumn) Validate

func (this *AuthColumn) Validate(obj interface{}) bool

type AuthEngine

type AuthEngine struct {
	TableMeta TableMetaReader `Inject:""`
	RoleMeta  RoleReader      `Inject:""`
}

权限引擎

func (*AuthEngine) ExistTable

func (this *AuthEngine) ExistTable(tablename string) bool

func (*AuthEngine) HasPermition

func (this *AuthEngine) HasPermition(tableTrigger string, parameters map[string]interface{}, roles ...string) bool

tableTrigger 触发标识,用于识别出对应的权限表 parameters 参数 roles 角色列表 如果触发的是不存在的权限控制,则认为拥有权限。如同空气不被控制,获取空气就认为是拥有权限的

type AuthField

type AuthField struct {
	Code  string //编码、字段名称
	Label string //名称
	Type  FType
}

元信息 权限字段

type AuthRow

type AuthRow map[string]*AuthColumn //所有列的值

权限数据

func (*AuthRow) Add

func (this *AuthRow) Add(f *AuthField, t ValueType, v string, negation bool)

func (*AuthRow) AddColumn

func (this *AuthRow) AddColumn(col *AuthColumn)

func (*AuthRow) HasPermition

func (this *AuthRow) HasPermition(parameters map[string]interface{}) bool

type AuthTable

type AuthTable struct {
	Code       string //编码
	Label      string //名称
	Fields     []AuthField
	AuthPolicy Policy //执行策略,1、拒绝 2、过滤 3、混淆
}

权限表定义

func (*AuthTable) Add

func (this *AuthTable) Add(code string, label string, t FType)

func (*AuthTable) AddField

func (this *AuthTable) AddField(f AuthField)

func (*AuthTable) GetField

func (this *AuthTable) GetField(fname string) AuthField

type FType

type FType byte

字段类型

const (
	URL FType = iota
	STRING
	INT
	DOUBLE
	BOOLEAN
	DATE
	DATETIME
)

类型定义

func ToFieldType

func ToFieldType(s string) FType

func (FType) ToString

func (this FType) ToString() string

func (*FType) UnmarshalYAML

func (this *FType) UnmarshalYAML(unmarshal func(interface{}) error) error

type Policy

type Policy byte

执行策略

const (
	P_DENY    Policy = 1 //拒绝
	P_FILTER  Policy = 2 //过滤
	P_OBSCURE Policy = 3 //混淆
)

type Role

type Role struct {
	Code        string //编码、字段名称
	Label       string //名称
	ParentRole  *Role  //父类角色
	ManagedRole *Role  //受管理角色
	// contains filtered or unexported fields
}

角色 1、由权限集合构成 2、可以继承角色,扩充被继承的角色 3、可以设置管控角色,角色的权限受制于管控角色 角色 管控角色 结果

T		  T			 T
F		  T			 F
T        F         F
F        F         F

func (*Role) AddRow

func (this *Role) AddRow(table string, row *AuthRow, veto bool)

按权限表加入权限数据

func (*Role) HasPermition

func (this *Role) HasPermition(tableTrigger string, parameters map[string]interface{}) bool

func (*Role) Init

func (this *Role) Init()

type RoleReader

type RoleReader interface {
	GetRole(string) *Role
}

角色信息读取器

type TableFile

type TableFile struct {
	Version     string
	Description string
	Tables      []AuthTable
}

type TableMetaReader

type TableMetaReader interface {
	GetTable(string) *AuthTable
}

原信息接口

type ValueType

type ValueType string

VT 值的类型

const (
	VT_SINGLES   ValueType = "S" //单个值
	VT_SET       ValueType = "T" //集合或者叫枚举
	VT_RANGE     ValueType = "R" //区间 [起始值;结束值]
	VT_REGEX     ValueType = "X" //正则表达式,复合正则表达式的允许
	VT_ALL       ValueType = "*" //允许所有值
	VT_MICRO     ValueType = "&" //宏,需要解释。例如 本部门、上级部门等
	VT_STARTWITH ValueType = "B" //以指定的值开头
	VT_ENDWITH   ValueType = "E" //以指定的值为结尾
)

type YamlFileTableMeta

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

func (*YamlFileTableMeta) GetTable

func (this *YamlFileTableMeta) GetTable(table string) *AuthTable

func (*YamlFileTableMeta) Load

func (this *YamlFileTableMeta) Load(f string)

Jump to

Keyboard shortcuts

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