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: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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