ac

package
v0.0.0-...-9138371 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2019 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TypeRole = iota
	TypePerm

	LogicalOR = iota
	LogicalAND
)

enum

Variables

This section is empty.

Functions

This section is empty.

Types

type BoxPerm

type BoxPerm struct {
	gorm.Model
	Roles []BoxRole `gorm:"many2many:box_role_perms;"`
	Name  string    `gorm:"not null;unique"`
	Desc  string    `gorm:"not null"`
}

BoxPerm Model

type BoxRole

type BoxRole struct {
	gorm.Model
	Users []BoxUser `gorm:"many2many:box_user_roles;"`
	Perms []BoxPerm `gorm:"many2many:box_role_perms;"`
	Name  string    `gorm:"not null;unique"`
	Desc  string    `gorm:"not null"`
}

BoxRole Model

type BoxUser

type BoxUser struct {
	gorm.Model
	Roles  []BoxRole `gorm:"many2many:box_user_roles;"`
	Name   string    `gorm:"not null;unique"`
	Nick   string    `gorm:"not null;unique"`
	Avatar string    `gorm:"not null"`
	Desc   string    `gorm:"not null"`
	Pass   string    `gorm:"not null"`
}

BoxUser Model

type Logical

type Logical uint8

Logical of AC

type Model

type Model struct {
	ID        uint
	CreatedAt time.Time
	UpdatedAt time.Time
}

Model -

type Rule

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

Rule for Access Control

func NewRule

func NewRule(rules []string, both bool) *Rule

NewRule Builder

func (*Rule) Check

func (r *Rule) Check(rules []string) bool

Check AC

type Srv

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

Srv AC

func New

func New(db *gorm.DB) *Srv

New AC Srv

func (*Srv) DelPerm

func (s *Srv) DelPerm(id []string) error

DelPerm 删除权限

func (*Srv) DeleteRole

func (s *Srv) DeleteRole(id []string) error

DeleteRole 删除角色

func (*Srv) DeleteUser

func (s *Srv) DeleteUser(id []string) error

DeleteUser -

func (*Srv) GetListPerm

func (s *Srv) GetListPerm(page, size int) []BoxPerm

GetListPerm 获取列表

func (*Srv) GetListRole

func (s *Srv) GetListRole(page, size int) []BoxRole

GetListRole -

func (*Srv) GetPerm

func (s *Srv) GetPerm(id int) *BoxPerm

GetPerm 查询权限

func (*Srv) GetPermCount

func (s *Srv) GetPermCount() int

GetPermCount 获取总数

func (*Srv) GetRole

func (s *Srv) GetRole(id uint) *BoxRole

GetRole 获取角色信息

func (*Srv) GetRoleCount

func (s *Srv) GetRoleCount() int

GetRoleCount 获取角色数量

func (*Srv) Login

func (s *Srv) Login(name, pass string) *BoxUser

Login Srv

func (*Srv) Perms

func (s *Srv) Perms(u *BoxUser) []string

Perms Selector

func (*Srv) PostPerm

func (s *Srv) PostPerm(a BoxPerm) error

PostPerm 增加权限

func (*Srv) PostRole

func (s *Srv) PostRole(name, desc string, rid []uint) error

PostRole 增加角色

func (*Srv) PostUser

func (s *Srv) PostUser(name, pass string, id []uint) error

PostUser -

func (*Srv) PutPerm

func (s *Srv) PutPerm(id int, a BoxPerm) error

PutPerm 更新权限

func (*Srv) PutRole

func (s *Srv) PutRole(name, desc string, id uint, rid []uint) error

PutRole 更新角色

func (*Srv) PutUser

func (s *Srv) PutUser(id uint, nick, pass, avatar, desc string, rid []uint) error

PutUser -

func (*Srv) Register

func (s *Srv) Register(name, pass string) bool

Register Srv

func (*Srv) Roles

func (s *Srv) Roles(u *BoxUser) []string

Roles Selector

func (*Srv) SelectByID

func (s *Srv) SelectByID(id uint) *BoxUser

SelectByID -

func (*Srv) SelectUser

func (s *Srv) SelectUser(id uint) *UserInfo

SelectUser -

func (*Srv) SelectUserList

func (s *Srv) SelectUserList(page, size int) []UserInfo

SelectUserList -

func (*Srv) SelectUsertotal

func (s *Srv) SelectUsertotal() int

SelectUsertotal -

type Type

type Type uint8

Type of AC

type UserInfo

type UserInfo struct {
	Model
	Roles  []BoxRole
	Name   string `json:"name"`
	Nick   string `json:"nick,omitempty"`
	Avatar string `json:"avatar,omitempty"`
	Desc   string `json:"desc,omitempty"`
}

UserInfo -

Jump to

Keyboard shortcuts

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