principal

package module
v0.0.0-...-25c2b5a Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2015 License: MIT Imports: 2 Imported by: 0

README

Principal

Build Status GoDoc Coverage Status license

Granular permissions and authorization management for the Go language based Flotilla web framework.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Anonymous = NewIdentity("anonymous", "anonymous")
)

Functions

func Necessary

func Necessary(h flotilla.HandlerFunc, permissions ...*Permission) flotilla.HandlerFunc

Necessary wraps a flotilla HandlerFunc with permissions, requiring that the current identity satifies all permissions fully before accessing the HandlerFunc.

func Sufficient

func Sufficient(h flotilla.HandlerFunc, perms ...*Permission) flotilla.HandlerFunc

Sufficient wraps a flotilla HandlerFunc with permissions, allowing access to the handler if the current identity is allowed for any given permission.

Types

type Conf

type Conf func(*Manager) error

func IdentityHandle

func IdentityHandle(fns ...IdentityHandler) Conf

func IdentityLoad

func IdentityLoad(fns ...IdentityLoader) Conf

func Unauthorized

func Unauthorized(fn flotilla.HandlerFunc) Conf

func UseSession

func UseSession() Conf

type Identity

type Identity struct {
	Id       string
	Provides *set.Set
}

func NewIdentity

func NewIdentity(id string, provides ...interface{}) *Identity

func (*Identity) Add

func (i *Identity) Add(provides ...interface{})

func (*Identity) Can

func (i *Identity) Can(p *Permission) bool

func (*Identity) Must

func (i *Identity) Must(p *Permission) bool

type IdentityHandler

type IdentityHandler func(*Identity, *flotilla.Ctx)

type IdentityLoader

type IdentityLoader func(*flotilla.Ctx) *Identity

type Manager

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

func New

func New(c ...Conf) *Manager

func (*Manager) Change

func (m *Manager) Change(i *Identity)

func (*Manager) Configure

func (p *Manager) Configure(c ...Conf) error

func (*Manager) Handle

func (m *Manager) Handle(i *Identity)

func (*Manager) Init

func (m *Manager) Init(app *flotilla.App)

func (*Manager) LoadIdentity

func (m *Manager) LoadIdentity(c *flotilla.Ctx) *Identity

func (*Manager) OnRequest

func (m *Manager) OnRequest(c *flotilla.Ctx)

func (*Manager) Unauthorized

func (m *Manager) Unauthorized(c *flotilla.Ctx)

type Permission

type Permission struct {
	Needs *set.Set
}

func NewPermission

func NewPermission(needs ...interface{}) *Permission

func (*Permission) Add

func (p *Permission) Add(needs ...interface{})

func (*Permission) Allows

func (p *Permission) Allows(i *Identity) bool

Allows checks the intersection of the permissions needs and the identity provides. Returns true if the intersection is not empty.

func (*Permission) Requires

func (p *Permission) Requires(i *Identity) bool

Requires checks that given identity provides all that the Permission needs. Returns true if the identity has all the permission needs.

Jump to

Keyboard shortcuts

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