enforcer

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2017 License: MIT Imports: 9 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

View Source
var CasbinConf = `` /* 275-byte string literal not displayed */
View Source
var (
	// DefaultConfig is the default CasbinAuth middleware config.
	DefaultConfig = Config{
		Skipper: middleware.DefaultSkipper,
	}
)

Functions

func Middleware

func Middleware(ce *casbin.Enforcer) echo.MiddlewareFunc

Middleware returns a CasbinAuth middleware.

For valid credentials it calls the next handler. For missing or invalid credentials, it sends "401 - Unauthorized" response.

func MiddlewareWithConfig

func MiddlewareWithConfig(config Config) echo.MiddlewareFunc

MiddlewareWithConfig returns a CasbinAuth middleware with config. See `Middleware()`.

func NewCasbinEnforcer

func NewCasbinEnforcer(connStr string) *casbin.Enforcer

Types

type Config

type Config struct {
	// Skipper defines a function to skip middleware.
	Skipper middleware.Skipper

	// Enforcer CasbinAuth main rule.
	// Required.
	Enforcer *casbin.Enforcer
}

Config defines the config for CasbinAuth middleware.

func (*Config) CheckPermission

func (a *Config) CheckPermission(c echo.Context) (bool, bool)

CheckPermission checks the user/method/path combination from the request. Returns true (permission granted) or false (permission forbidden)

func (*Config) GetUserName

func (a *Config) GetUserName(c echo.Context) (username string)

GetUserName gets the user name from the request. Currently, only HTTP basic authentication is supported

Jump to

Keyboard shortcuts

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