casbin

package
v0.0.0-...-96f2668 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2024 License: MIT Imports: 7 Imported by: 0

README

Casbin

Casbin(https://github.com/casbin/casbin)是一套访问控制开源库,致力于帮助复杂系统解决权限管理的难题。同时也是一个国产开源项目。Casbin采用了元模型的设计思想,既支持ACL(访问控制列表),RBAC(基于角色访问控制),ABAC(基于属性访问控制)等经典的访问控制模型,也支持用户按照自身需求灵活定义权限。Casbin已经被Intel、IBM、腾讯云、VMware、RedHat、T-Mobile等公司开源使用,被Cisco、Verizon等公司闭源使用。具体详见Casbin主页(https://casbin.org/)。

Casbin由北京大学罗杨博士在2017年4月发起,罗杨博士的研究方向为云计算访问控制,目前已发表数十篇相关学术论文,曾经在ICWS、IEEE CLOUD、ICICS等多个顶级学术会议进行论文宣讲。Casbin项目则是其研究成果的落地。

Casbin最初是一个用Go语言打造的开源轻量级的统一访问控制框架。目前已逐渐发展,扩展到Go、Java、Node.js、Javascript(React)、Python、PHP、.NET、Delphi、Rust等多种语言,在GitHub开源(https://github.com/casbin/casbin),主项目在GitHub上已有1.3w+ stars。该项目目前已经有一个上百人稳定的团队进行维护,并在持续不断发展中。

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultAbacModel string
View Source
var DefaultAclModel string
View Source
var DefaultRbacModel string
View Source
var DefaultRbacWithDomainModel string
View Source
var DefaultRestfullModel string
View Source
var DefaultRestfullWithRoleModel string

Functions

This section is empty.

Types

type Adapter

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

func (*Adapter) AddPolicy

func (sa *Adapter) AddPolicy(_ string, _ string, _ []string) error

func (*Adapter) LoadPolicy

func (sa *Adapter) LoadPolicy(model model.Model) error

func (*Adapter) RemoveFilteredPolicy

func (sa *Adapter) RemoveFilteredPolicy(_ string, _ string, _ int, _ ...string) error

func (*Adapter) RemovePolicy

func (sa *Adapter) RemovePolicy(_ string, _ string, _ []string) error

func (*Adapter) SavePolicy

func (sa *Adapter) SavePolicy(_ model.Model) error

func (*Adapter) SetPolicies

func (sa *Adapter) SetPolicies(policies map[string]interface{})

type Option

type Option func(*State)

func WithEnforcer

func WithEnforcer(enforcer stdcasbin.IEnforcer) Option

func WithFileModel

func WithFileModel(path string) Option

func WithModel

func WithModel(model model.Model) Option

func WithPolicyAdapter

func WithPolicyAdapter(policy persist.Adapter) Option

func WithStringModel

func WithStringModel(str string) Option

type PolicyRule

type PolicyRule struct {
	PType string `json:"p_type,omitempty"`
	V0    string `json:"v0,omitempty"`
	V1    string `json:"v1,omitempty"`
	V2    string `json:"v2,omitempty"`
	V3    string `json:"v3,omitempty"`
	V4    string `json:"v4,omitempty"`
	V5    string `json:"v5,omitempty"`
}

func (PolicyRule) LoadPolicyLine

func (line PolicyRule) LoadPolicyLine(model model.Model) error

type State

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

func NewAuthorized

func NewAuthorized(_ context.Context, opts ...Option) (*State, error)

func (*State) FilterAuthorizedPairs

func (s *State) FilterAuthorizedPairs(_ context.Context, subjects authz.Subjects, pairs authz.Pairs) (authz.Pairs, error)

func (*State) FilterAuthorizedProjects

func (s *State) FilterAuthorizedProjects(_ context.Context, subjects authz.Subjects) (authz.Projects, error)

func (*State) IsAuthorized

func (s *State) IsAuthorized(_ context.Context, subject authz.Subject, action authz.Action, resource authz.Resource, project authz.Project) (bool, error)

func (*State) ProjectsAuthorized

func (s *State) ProjectsAuthorized(_ context.Context, subjects authz.Subjects, action authz.Action, resource authz.Resource, projects authz.Projects) (authz.Projects, error)

func (*State) SetPolicies

func (s *State) SetPolicies(_ context.Context, policyMap authz.PolicyMap, _ authz.RoleMap) error

Jump to

Keyboard shortcuts

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