kk_abac

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2024 License: BSD-3-Clause Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action string

Action 操作类型

type Attribute

type Attribute struct {
	Name  string
	Value string
}

Attribute 定义一个属性 可以是用户属性、资源属性、环境属性等

type Condition

type Condition func(subject Subject, object Object) bool

Condition 复杂条件,用于策略中的额外条件判断

type Object

type Object struct {
	Attributes []Attribute
}

Object 要被访问的资源对象

type Policy

type Policy struct {
	Effect     bool // 是否允许(true: 允许, false: 拒绝)
	Action     Action
	Subjects   [][]Attribute
	Objects    [][]Attribute
	Conditions []Condition // 可选,用于更复杂的条件判断
}

Policy 策略 定义哪些属性组合(Subject)可以执行哪些操作(Object)

type PolicyEnforcer

type PolicyEnforcer struct {
	Policies []Policy
}

PolicyEnforcer 策略执行器 根据当前的环境、用户和资源属性,以及策略,判断请求是否合法。

func (*PolicyEnforcer) Evaluate

func (pe *PolicyEnforcer) Evaluate(subject Subject, object Object, action Action) bool

Evaluate 检查请求是否符合任何策略

type Subject

type Subject struct {
	Attributes []Attribute
}

Subject 主体 如用户

Directories

Path Synopsis
casbin

Jump to

Keyboard shortcuts

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