Documentation
¶
Index ¶
- Constants
- func AuthMiddlewareErrHandler(_ *echo.Context, err error) error
- func DefaultVersionHeaderSkipper(_ *echo.Context) bool
- func KeyAuthExtended(config KeyAuthExtendedConfig) echo.MiddlewareFunc
- func StreamAuthorizer(config *config.Config, flagsetManager service.FlagsetManager) echo.MiddlewareFunc
- func VersionHeader(cfg VersionHeaderConfig) echo.MiddlewareFunc
- type KeyAuthExtendedConfig
- type VersionHeaderConfig
Constants ¶
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 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.