auth

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2020 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

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

func MiddlewareWithConfig

func MiddlewareWithConfig(config Config) echo.MiddlewareFunc

func Skipper

func Skipper(c echo.Context) bool

skipper 这些不需要token

func Validator

func Validator(token string, c echo.Context) (bool, error)

Validator 校验token是否合法,顺便根据token在 context中赋值 user id

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(e echo.Context) (bool, error)

Jump to

Keyboard shortcuts

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