Documentation ¶
Index ¶
- Variables
- func Necessary(h flotilla.HandlerFunc, permissions ...*Permission) flotilla.HandlerFunc
- func Sufficient(h flotilla.HandlerFunc, perms ...*Permission) flotilla.HandlerFunc
- type Conf
- type Identity
- type IdentityHandler
- type IdentityLoader
- type Manager
- func (m *Manager) Change(i *Identity)
- func (p *Manager) Configure(c ...Conf) error
- func (m *Manager) Handle(i *Identity)
- func (m *Manager) Init(app *flotilla.App)
- func (m *Manager) LoadIdentity(c *flotilla.Ctx) *Identity
- func (m *Manager) OnRequest(c *flotilla.Ctx)
- func (m *Manager) Unauthorized(c *flotilla.Ctx)
- type Permission
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 ¶
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 ¶
func NewIdentity ¶
func (*Identity) Can ¶
func (i *Identity) Can(p *Permission) bool
func (*Identity) Must ¶
func (i *Identity) Must(p *Permission) bool
type IdentityHandler ¶
type IdentityLoader ¶
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
func (*Manager) Unauthorized ¶
type Permission ¶
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.
Click to show internal directories.
Click to hide internal directories.