rbac

package
v0.0.0-...-0a224c4 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2016 License: Apache-2.0 Imports: 6 Imported by: 35

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckCacheTimeout

func CheckCacheTimeout()

func GetAllTokenExpiredTime

func GetAllTokenExpiredTime() map[string]time.Time

func GetPermissionName

func GetPermissionName(component string, method string, path string) (string, error)

func GetResourceName

func GetResourceName(component string, path string) (string, error)

func SetCache

func SetCache(token string, user *User, ttl time.Duration)

Types

type Cache

type Cache struct {
	Token       string
	User        *User
	CreatedTime time.Time
	ExpiredTime time.Time
}

type Permission

type Permission struct {
	Name      string
	Component string
	Method    string
	Path      string // Path is hierarchy
}

func CreatePermission

func CreatePermission(component string, method string, path string) (*Permission, error)

func (*Permission) HasChildPermission

func (permission *Permission) HasChildPermission(component string, method string, path string) bool

Check whether user has the target permission node or child permission node of the target permission node along the tree

func (*Permission) HasPermission

func (permission *Permission) HasPermission(component string, method string, path string) bool

type Resource

type Resource struct {
	Name      string
	Component string
	Path      string // Path is hierarchy
}

func CreateResource

func CreateResource(component string, path string) (*Resource, error)

func (*Resource) HasResource

func (resource *Resource) HasResource(component string, path string) bool

type Role

type Role struct {
	Name            string
	PermissionSlice []*Permission
	Description     string
}

func (*Role) HasChildPermission

func (role *Role) HasChildPermission(component string, method string, path string) bool

Check whether user has the target permission node or child permission node of the target permission node along the tree

func (*Role) HasPermission

func (role *Role) HasPermission(component string, method string, path string) bool

type User

type User struct {
	Name            string
	EncodedPassword string
	RoleSlice       []*Role
	ResourceSlice   []*Resource
	Description     string
	MetaDataMap     map[string]string // Used to store user's data which doesn't need to check password
	ExpiredTime     *time.Time
	Disabled        bool
}

func CreateUser

func CreateUser(name string, password string, roleSlice []*Role, resourceSlice []*Resource, description string, metaDataMap map[string]string, expiredTime *time.Time, disabled bool) *User

func GetCache

func GetCache(token string) *User

func (*User) CheckPassword

func (user *User) CheckPassword(password string) bool

func (*User) CopyPartialUserDataForComponent

func (user *User) CopyPartialUserDataForComponent(component string) *User

func (*User) HasChildPermission

func (user *User) HasChildPermission(component string, method string, path string) bool

Check whether user has the target permission node or child permission node of the target permission node along the tree. This doesn't mean user has permission to access the parent permission node in the tree but just is able to bypass the parent permission node in order to go down to the target child permission node in the tree.

func (*User) HasPermission

func (user *User) HasPermission(component string, method string, path string) bool

func (*User) HasResource

func (user *User) HasResource(component string, path string) bool

Jump to

Keyboard shortcuts

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