permissions

package
v0.0.0-...-9f56b5f Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2018 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ErrInvalidActions is returned when an invalid permissions value is attempted to be set
	ErrInvalidActions = errors.Error("invalid permissions, please see constant block for reference")
	// ErrPermissionsUnchanged is returned when matching permissions are set for a resource
	ErrPermissionsUnchanged = errors.Error("permissions match, unchanged")
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action uint8

Action represents an action type

const (
	// ActionNone represents a zero value, no action
	ActionNone Action = 1 << iota
	// ActionRead represents a reading action
	ActionRead
	// ActionWrite represents a writing action
	ActionWrite
	// ActionDelete represents a deleting action
	ActionDelete
)

func (Action) Can

func (a Action) Can(ar Action) (can bool)

Can will return if an action can peform an action request

type Permissions

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

Permissions manages permissions

func New

func New(dir string) (pp *Permissions, err error)

New will return a new instance of Permissions

func (*Permissions) AddGroup

func (p *Permissions) AddGroup(uuid string, grouplist ...string) (err error)

AddGroup will add a group to a uuid

func (*Permissions) Can

func (p *Permissions) Can(uuid, id string, action Action) (can bool)

Can will return if a user (UUID) can perform a given action on a provided resource id

func (*Permissions) Close

func (p *Permissions) Close() (err error)

Close will close permissions

func (*Permissions) Get

func (p *Permissions) Get(id, group string) (actions Action)

Get will get the permissions for a given group for a resource id

func (*Permissions) Groups

func (p *Permissions) Groups(uuid string) (gs []string, err error)

Groups will return a slice of the groups a user belongs to

func (*Permissions) Has

func (p *Permissions) Has(id, group string) (ok bool)

Has will return whether or not an ID has a particular group associated with it

func (*Permissions) RemoveGroup

func (p *Permissions) RemoveGroup(uuid string, grouplist ...string) (err error)

RemoveGroup will remove a group to a uuid

func (*Permissions) SetPermissions

func (p *Permissions) SetPermissions(id, group string, actions Action) (err error)

SetPermissions will set the permissions for a given group for a resource id

Jump to

Keyboard shortcuts

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