middlewares

package
v1.12.0 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2024 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrJWTMissing = echo.NewHTTPError(http.StatusBadRequest, "missing or malformed jwt")
	ErrJWTInvalid = echo.NewHTTPError(http.StatusUnauthorized, "invalid or expired jwt")
)

Errors

View Source
var DefaultRecoverConfig = middleware.RecoverConfig{
	Skipper:           middleware.DefaultSkipper,
	StackSize:         4 << 10,
	DisableStackAll:   false,
	DisablePrintStack: false,
	LogLevel:          0,
}

DefaultRecoverConfig is the default Recover middleware config.

Functions

func Authorizer

func Authorizer(core *security.ServiceCore) func(logger *zap.SugaredLogger, scopes ...string) echo.MiddlewareFunc

func JWTHandler

func JWTHandler(config *JwtConfig) echo.MiddlewareFunc

func LoggerFilter

func LoggerFilter(config LoggerConfig) echo.MiddlewareFunc

func NoOpAuthorizer

func NoOpAuthorizer(logger *zap.SugaredLogger, scopes ...string) echo.MiddlewareFunc

func RecoverWithConfig

func RecoverWithConfig(config middleware.RecoverConfig, logger *zap.SugaredLogger) echo.MiddlewareFunc

Types

type JSONWebKeys

type JSONWebKeys struct {
	Kty string   `json:"kty"`
	Kid string   `json:"kid"`
	Use string   `json:"use"`
	N   string   `json:"n"`
	E   string   `json:"e"`
	X5c []string `json:"x5c"`
}

type Jwks

type Jwks struct {
	Keys []JSONWebKeys `json:"keys"`
}

type JwtConfig

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

	// BeforeFunc defines a function which is executed just before the middleware.
	BeforeFunc middleware.BeforeFunc

	Cache     *jwk.Cache
	Wellknown string
	Audience  []string
	Issuer    []string

	// This is set if Node security is enabled
	NodePublicKey *rsa.PublicKey
	NodeAudience  []string
	NodeIssuer    []string
}

func (*JwtConfig) ValidateToken

func (config *JwtConfig) ValidateToken(auth string) (*jwt.Token, error)

type LoggerConfig

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

	// BeforeFunc defines a function which is executed just before the middleware.
	BeforeFunc middleware.BeforeFunc

	Logger *zap.Logger

	StatsdClient statsd.ClientInterface
}

type Response

type Response struct {
	Message string `json:"message"`
}

Jump to

Keyboard shortcuts

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