sdcasbin

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package sdcasbin Casbin 扩展

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrIllegalUserId   = sderr.Sentinel("illegal user id")
	ErrIllegalRoleId   = sderr.Sentinel("illegal role id")
	ErrIllegalObjectId = sderr.Sentinel("illegal object id")
	ErrIllegalAction   = sderr.Sentinel("illegal action")
)

Functions

This section is empty.

Types

type Grant

type Grant struct {
	RoleId   string
	ObjectId string
	Actions  []string
}

func G

func G(roleId string) Grant

func (Grant) On

func (g Grant) On(actions ...string) Grant

func (Grant) To

func (g Grant) To(oid string) Grant

type Object

type Object struct {
	Id               string
	AvailableActions []string
}

func O

func O(oid string, availableActions ...string) Object

type ObjectSet

type ObjectSet struct {
	Ids              []string
	AvailableActions []string
}

type Rbac

type Rbac interface {
	IsGranted(userOrRoleId, objId, action string) bool
}

type RbacEnforcerBuilder

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

func NewRbacEnforcerBuilder

func NewRbacEnforcerBuilder(opts *RbacEnforcerBuilderOptions) *RbacEnforcerBuilder

func (*RbacEnforcerBuilder) AddObjectIds

func (b *RbacEnforcerBuilder) AddObjectIds(objIds []string, availableActions []string) *RbacEnforcerBuilder
func (b *RbacEnforcerBuilder) AddObjectRoleLink(objId string, roleOrUserIds []string, actions []string) error

func (*RbacEnforcerBuilder) AddObjects

func (b *RbacEnforcerBuilder) AddObjects(objs ...Object) *RbacEnforcerBuilder

func (*RbacEnforcerBuilder) AddRoleIds

func (b *RbacEnforcerBuilder) AddRoleIds(roleIds ...string) *RbacEnforcerBuilder
func (b *RbacEnforcerBuilder) AddRoleRoleLink(childRoleId string, parentRoleIds []string) error

func (*RbacEnforcerBuilder) AddUserIds

func (b *RbacEnforcerBuilder) AddUserIds(uids ...string) *RbacEnforcerBuilder
func (b *RbacEnforcerBuilder) AddUserRoleLink(userIds []string, roleIds []string) error

func (*RbacEnforcerBuilder) Build

func (b *RbacEnforcerBuilder) Build() (*casbin.Enforcer, error)

func (*RbacEnforcerBuilder) Clear

func (*RbacEnforcerBuilder) GeneratePolicies

func (b *RbacEnforcerBuilder) GeneratePolicies() string

type RbacEnforcerBuilderOptions

type RbacEnforcerBuilderOptions struct {
	DisableCheck        bool
	SuperuserId         string
	AllowObjectUserLink bool
}

type RbacLoader

type RbacLoader interface {
	Prepare(b *RbacEnforcerBuilder)
	Load(b *RbacEnforcerBuilder)
}

type RbacLoaderFactory

type RbacLoaderFactory interface {
	NewRbacLoader() RbacLoader
}

func RbacLoaderAsFactory

func RbacLoaderAsFactory(f func(b *RbacEnforcerBuilder)) RbacLoaderFactory

type RbacLoaderFactoryFunc

type RbacLoaderFactoryFunc func() RbacLoader

func (RbacLoaderFactoryFunc) NewRbacLoader

func (f RbacLoaderFactoryFunc) NewRbacLoader() RbacLoader

type RbacLoaderFunc

type RbacLoaderFunc func(b *RbacEnforcerBuilder)

func (RbacLoaderFunc) Load

func (RbacLoaderFunc) Prepare

func (f RbacLoaderFunc) Prepare(b *RbacEnforcerBuilder)

type RbacPlan

type RbacPlan struct {
	SuperRole    string
	DisableCheck bool
	Users        []User
	Objects1     []Object
	Objects2     []Object
	Objects3     []Object
	Grants1      []Grant
	Grants2      []Grant
	Grants3      []Grant
}

func (RbacPlan) Apply

func (plan RbacPlan) Apply(b *RbacEnforcerBuilder) error

func (RbacPlan) Load

func (plan RbacPlan) Load(b *RbacEnforcerBuilder)

func (RbacPlan) MustToRbac

func (plan RbacPlan) MustToRbac() Rbac

func (RbacPlan) Prepare

func (plan RbacPlan) Prepare(b *RbacEnforcerBuilder)

func (RbacPlan) ToRbac

func (plan RbacPlan) ToRbac() (Rbac, error)

type ReloadableRbac

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

func NewReloadableRbac

func NewReloadableRbac(
	loaders []RbacLoader,
	loaderFactories []RbacLoaderFactory,
	enforcerBuilderOpts *RbacEnforcerBuilderOptions,
) *ReloadableRbac

func (*ReloadableRbac) IsGranted

func (rbac *ReloadableRbac) IsGranted(userOrRoleId, objId, action string) bool

func (*ReloadableRbac) Policies

func (rbac *ReloadableRbac) Policies() string

func (*ReloadableRbac) Reload

func (rbac *ReloadableRbac) Reload() error

type StaticRbac

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

func NewStaticRbac

func NewStaticRbac(loaders []RbacLoader, enforcerBuilderOpts *RbacEnforcerBuilderOptions) (*StaticRbac, error)

func NewStaticRbacWithFunc

func NewStaticRbacWithFunc(f func(b *RbacEnforcerBuilder), enforcerBuilderOpts *RbacEnforcerBuilderOptions) (*StaticRbac, error)

func (*StaticRbac) IsGranted

func (rbac *StaticRbac) IsGranted(userOrRoleId, objId, action string) bool

type User

type User struct {
	Id      string
	RoleIds []string
}

func U

func U(uid string, roleIds ...string) User

Jump to

Keyboard shortcuts

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