middleware

package
v0.0.0-...-8b4736f Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2017 License: GPL-3.0 Imports: 10 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 (
	DefaultTokenAuthConfig = TokenAuthConfig{
		Skipper:     defaultSkipper,
		ContextKey:  "remote_user",
		TokenLookup: "header:" + echo.HeaderAuthorization,
		AuthScheme:  "Token",
	}
)
View Source
var (
	NoneAuthUrls map[string][]string = map[string][]string{
		"ALL": []string{"/login", "/register", "/forget", "/reset", "/captcha"},
		"GET": []string{"/file/view"},
	}
)

Functions

func ContentTypeCheckerMiddleware

func ContentTypeCheckerMiddleware() echo.MiddlewareFunc

func Hash

func Hash(token string) string

Hash applies a simple MD5 hash over a token, making it safe to store

func New

func New() (string, error)

Generate a random token

func TokenAuthMiddleware

func TokenAuthMiddleware() echo.MiddlewareFunc

Default middleware

func TokenAuthSkipper

func TokenAuthSkipper(c echo.Context) bool

Skip request that's in NoneAuthUrls

func TokenAuthWithConfig

func TokenAuthWithConfig(config TokenAuthConfig) echo.MiddlewareFunc

Add middleware of token with config

func TokenIdentify

func TokenIdentify(token string) string

Read from storage -- redis or memory

func XPoweredByMiddleware

func XPoweredByMiddleware() echo.MiddlewareFunc

Types

type ContentTypeCheckerConfig

type ContentTypeCheckerConfig struct {
	Skipper middleware.Skipper
}
var (
	NoneJsonUrls map[string][]string = map[string][]string{
		"ALL": []string{"/upload", "/download", "/thumb"},
	}
	DefaultContentTypeCheckerConfig ContentTypeCheckerConfig = ContentTypeCheckerConfig{
		Skipper: contentTypeCheckerSkipper,
	}
)

type TokenAuthConfig

type TokenAuthConfig struct {
	Skipper middleware.Skipper

	// Context key to store user information from the token into context.
	// Optional. Default value "remote_user".
	ContextKey string

	// TokenLookup is a string in the form of "<source>:<name>" that is used
	// to extract token from the request.
	// Optional. Default value "header:Authorization".
	// Possible values:
	// - "header:<name>"
	// - "query:<name>"
	// - "cookie:<name>"
	TokenLookup string

	// AuthScheme to be used in the Authorization header.
	// Optional. Default value "Token".
	AuthScheme string
}

Jump to

Keyboard shortcuts

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