middleware

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2026 License: MIT Imports: 7 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

View Source
const (
	// VersionHeaderName is the response header carrying the version of the relay proxy.
	VersionHeaderName = "X-Semaphore-Version"
	// LegacyVersionHeaderName is the name GO Feature Flag used for the same header, still sent
	// next to VersionHeaderName for the clients that read it.
	LegacyVersionHeaderName = "X-Gofeatureflag-Version"
)

Variables

This section is empty.

Functions

func AuthMiddlewareErrHandler

func AuthMiddlewareErrHandler(_ *echo.Context, err error) error

func DefaultVersionHeaderSkipper

func DefaultVersionHeaderSkipper(_ *echo.Context) bool

func KeyAuthExtended

func KeyAuthExtended(config KeyAuthExtendedConfig) echo.MiddlewareFunc

KeyAuthExtended is a middleware that extends middleware.KeyAuthWithConfig to also check the X-API-Key header in addition to the standard Authorization header.

func StreamAuthorizer

func StreamAuthorizer(config *config.Config, flagsetManager service.FlagsetManager) echo.MiddlewareFunc

StreamAuthorizer is a middleware that checks the apiKey query param to authorize streaming connections (websocket / SSE). In flag set mode (flagsetManager is not nil) a key is accepted if it routes to a flag set, and the name of the flag set resolved here is the one the handler uses.

func VersionHeader

func VersionHeader(cfg VersionHeaderConfig) echo.MiddlewareFunc

VersionHeader is a middleware that adds the version of the relay proxy in the headers VersionHeaderName and LegacyVersionHeaderName.

Types

type KeyAuthExtendedConfig

type KeyAuthExtendedConfig struct {
	// Validator is a function to validate the API key.
	// It receives the key and the context, and returns true if the key is valid.
	Validator middleware.KeyAuthValidator

	// ErrorHandler is a function to handle errors when authentication fails.
	ErrorHandler middleware.KeyAuthErrorHandler

	// 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:Bearer ".
	// Possible values:
	// - "header:<name>" or "header:<name>:<cut-prefix>" - extracts key from the request header
	// - "query:<name>" - extracts key from the query string
	// - "form:<name>" - extracts key from the form
	// - "cookie:<name>" - extracts key from the cookie
	KeyLookup string
}

KeyAuthExtendedConfig defines the configuration for the extended key auth middleware. It extends middleware.KeyAuthConfig to also check the X-API-Key header.

type VersionHeaderConfig

type VersionHeaderConfig struct {
	Skipper          middleware.Skipper
	RelayProxyConfig *config.Config
}

VersionHeaderConfig defines the configuration for the middleware.

Jump to

Keyboard shortcuts

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