guard

package
v0.0.0-...-6907ca9 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2018 License: MIT Imports: 6 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AdminAccess

func AdminAccess(u *auth.User) apperror.Error

AdminAccess is a auth middleware that filters out non admin users

func LoggedUserAccess

func LoggedUserAccess(u *auth.User) apperror.Error

LoggedUserAccess is a auth middleware that filters out anonymous users

Types

type Guard

type Guard struct {
	// ParamStruct is an instance of a struct that describes the http params
	// accepted by an endpoint
	ParamStruct interface{}

	// Auth is used to add a auth middleware
	Auth RouteAuth
}

Guard represents a security access system for routes

func (*Guard) HasAccess

func (g *Guard) HasAccess(u *auth.User) (bool, apperror.Error)

HasAccess check if a given user has access to the

func (*Guard) ParseParams

func (g *Guard) ParseParams(sources map[string]url.Values, fileHolder formfile.FileHolder) (interface{}, error)

ParseParams parses and returns the list of params needed Returns an error if a required param is missing, or if a type is wrong

type RouteAuth

type RouteAuth func(*auth.User) apperror.Error

RouteAuth represents a middleware used to allow/block the access to an endpoint

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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