authorization

package
v0.0.0-...-89bec85 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2023 License: MIT Imports: 11 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddSubjectGroup

func AddSubjectGroup(subject, group, tenantId string) (bool, error)

func AddSubjectResource

func AddSubjectResource(subject string, resourceTarget, action, tenantId, resourceId string) (bool, error)

func CheckSubjectPermissions

func CheckSubjectPermissions(subject, resource, action, tenantId string) bool

func GetSubjectGroupIds

func GetSubjectGroupIds(subject, tenantId string) ([]string, error)

func GetSubjectResourceIds

func GetSubjectResourceIds(subject string, tenantId string) (isSuperAdmin bool, ids []string, err error)

func GetSubjectResources

func GetSubjectResources(subject, tenantId string) [][]string

func Init

func Init()

func NewAdapter

func NewAdapter(engine *xorm.Engine) (*adapter, error)

func RemoveSubjectGroup

func RemoveSubjectGroup(subject, group, tenantId string) (bool, error)

func RemoveSubjectGroups

func RemoveSubjectGroups(subject, tenantId string) (bool, error)

func RemoveSubjectResource

func RemoveSubjectResource(subject string, resourceTarget, action, tenantId, resourceId string) (bool, error)

func RemoveSubjectResources

func RemoveSubjectResources(subject string) (bool, error)

func SetSuperAdmin

func SetSuperAdmin(admin string)

Types

type CasbinPolicy

type CasbinPolicy struct {
	Id         string `json:"id" xorm:"pk varchar(50)"`
	PolicyType int    `json:"policyType" xorm:"comment('策略类型 1-p, 2-p2')"`  // p  p2
	SubjectId  string `json:"subjectId" xorm:"comment('策略主体ID')"`           // 主体
	Resource   string `json:"resource" xorm:"comment('资源内容')"`              // 资源
	Action     string `json:"action" xorm:"comment('资源使用行为')"`              // 方法
	Effect     int    `json:"effect" xorm:"comment('策略行为 1-allow,2-deny')"` // 1 allow / 2 deny
	Priority   int    `json:"priority" xorm:"comment('优先级')"`               // 优先级
	TenantId   string `json:"tenantId" xorm:"comment('租户ID')"`
	ResourceId string `json:"resourceId" xorm:"varchar(50) comment('对应的资源ID')"` // 资源ID
}

type CasbinRelationship

type CasbinRelationship struct {
	Id              string `json:"id,omitempty" xorm:"pk varchar(50)"`
	RelationType    int    `json:"relationType,omitempty" xorm:"comment('关系类型 1-g 2-g2')"`
	SubjectId       string `json:"subjectId,omitempty" xorm:"comment('主体ID')"`
	ParentSubjectId string `json:"parentSubjectId,omitempty" xorm:"comment('继承主体ID')"`
	TenantId        string `json:"tenantId" xorm:"comment('租户ID')"`
}

Jump to

Keyboard shortcuts

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