middleware

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2019 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Casbin

func Casbin(config *CasbinConfig) (buffalo.MiddlewareFunc, error)

Casbin creates a new casbin enforcer for the provided config and returns a permission checking middleware.

func NewCasbinEnforcer

func NewCasbinEnforcer(config *CasbinConfig) error

NewCasbinEnforcer creates and sets a new casbin enforcer for the provided Config. A gorm adapter is used for storage. `model.conf` from the config box is used for model configuration.

Types

type CasbinConfig

type CasbinConfig struct {
	// Connection provides a database connection.
	Connection *pop.Connection
	// Anonymous defines the default "group" for users that are not logged in.
	Anonymous string
	// RedirectionURL is the location to which an denied access should redirect.
	RedirectionURL string
	// ConfigBox provides access to the casbin configuration files.
	ConfigBox packr.Box
	// Enforcer will be set by NewCasbinEnforcer.
	Enforcer *casbin.Enforcer
}

CasbinConfig provides configuration information for the casbin middleware.

func (*CasbinConfig) InitializeRoles

func (config *CasbinConfig) InitializeRoles()

InitializeRoles reads roles.csv from the config box and applies the permission definitions (casbin policy).

Jump to

Keyboard shortcuts

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