middleware

package
v0.0.0-...-0b15fe8 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2019 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// DefaultKeyAuthConfig is the default KeyAuth middleware config.
	DefaultKeyAuthConfig = KeyAuthConfig{
		Skipper:    middleware.DefaultSkipper,
		KeyLookup:  "header:" + echo.HeaderAuthorization,
		AuthScheme: "Bearer",
	}
)

Functions

func AuthApiKey

func AuthApiKey(cfg domain.SpringCloudConfig) echo.MiddlewareFunc

func AuthBasic

func AuthBasic(cfg domain.SpringCloudConfig) echo.MiddlewareFunc

func KeyAuth

func KeyAuth(fn KeyAuthValidator) echo.MiddlewareFunc

KeyAuth returns an KeyAuth middleware.

For valid key it calls the next handler. For invalid key, it sends "401 - Unauthorized" response. For missing key, it sends "400 - Bad Request" response.

func KeyAuthWithConfig

func KeyAuthWithConfig(config KeyAuthConfig) echo.MiddlewareFunc

KeyAuthWithConfig returns an KeyAuth middleware with config. See `KeyAuth()`.

Types

type KeyAuthConfig

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

	// KeyLookup is a string in the form of "<source>:<name>" that is used
	// to extract key from the request.
	// Optional. Default value "header:Authorization".
	// Possible values:
	// - "header:<name>"
	// - "query:<name>"
	// - "form:<name>"
	KeyLookup string `yaml:"key_lookup"`

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

	// Validator is a function to validate key.
	// Required.
	Validator KeyAuthValidator
}

KeyAuthConfig defines the config for KeyAuth middleware.

type KeyAuthValidator

type KeyAuthValidator func(string, echo.Context) (bool, error)

KeyAuthValidator defines a function to validate KeyAuth credentials.

Jump to

Keyboard shortcuts

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