permset

package
v0.2.12 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2021 License: AGPL-3.0 Imports: 2 Imported by: 2

Documentation

Overview

Package permset provides primitives for permission management.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewContext

func NewContext(ctx context.Context, permset Permset) context.Context

NewContext receives perms and returns a context with the received perms are the value of the context.

Types

type Perm

type Perm int

Perm is a permission to do some action.

type Permset

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

Permset represents a set of permissions.

func FromContext

func FromContext(ctx context.Context) (Permset, error)

FromContext receives a context and returns the permset in it.

func New

func New(perms ...Perm) Permset

New receives permissions to contain and returns a permset from it.

func (*Permset) Add

func (ps *Permset) Add(perms ...Perm)

Add adds the received perms to the permset.

func (*Permset) Contains

func (ps *Permset) Contains(perm Perm) bool

Contains receives single Perm and returns true if the permset contains it.

func (*Permset) ContainsAll

func (ps *Permset) ContainsAll(perms ...Perm) bool

ContainsAll returns true if the permset contains all received Perms.

func (*Permset) ContainsNone

func (ps *Permset) ContainsNone(perms ...Perm) bool

ContainsNone returns true if the permset contains none one of the received Perms.

func (*Permset) ContainsSome

func (ps *Permset) ContainsSome(perms ...Perm) bool

ContainsSome returns true if the permset contains any one or more of the received Perms.

func (*Permset) Perms

func (ps *Permset) Perms() []Perm

Perms returns the permissions contained within the permset.

func (*Permset) Remove

func (ps *Permset) Remove(perms ...Perm)

Remove removes the received perms from the permset.

Jump to

Keyboard shortcuts

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