Documentation
¶
Overview ¶
Package upstreamswap provides middleware for exchanging embedded auth server access tokens with upstream IdP tokens.
Index ¶
Constants ¶
const ( // HeaderStrategyReplace replaces the Authorization header with the upstream token. HeaderStrategyReplace = "replace" // HeaderStrategyCustom adds the upstream token to a custom header. HeaderStrategyCustom = "custom" )
Header injection strategy constants
const MiddlewareType = "upstreamswap"
MiddlewareType is the type identifier for upstream swap middleware.
Variables ¶
This section is empty.
Functions ¶
func CreateMiddleware ¶
func CreateMiddleware(config *types.MiddlewareConfig, runner types.MiddlewareRunner) error
CreateMiddleware is the factory function for upstream swap middleware.
Types ¶
type Config ¶
type Config struct {
// HeaderStrategy determines how to inject the token: "replace" (default) or "custom".
HeaderStrategy string `json:"header_strategy,omitempty" yaml:"header_strategy,omitempty"`
// CustomHeaderName is the header name when HeaderStrategy is "custom".
CustomHeaderName string `json:"custom_header_name,omitempty" yaml:"custom_header_name,omitempty"`
}
Config holds configuration for upstream swap middleware.
type Middleware ¶
type Middleware struct {
// contains filtered or unexported fields
}
Middleware wraps the upstream swap middleware functionality.
func (*Middleware) Close ¶
func (*Middleware) Close() error
Close cleans up any resources used by the middleware.
func (*Middleware) Handler ¶
func (m *Middleware) Handler() types.MiddlewareFunction
Handler returns the middleware function used by the proxy.
type MiddlewareParams ¶
type MiddlewareParams struct {
Config *Config `json:"config,omitempty"`
}
MiddlewareParams represents the JSON parameters for the middleware factory.
type StorageGetter ¶
type StorageGetter func() storage.UpstreamTokenStorage
StorageGetter is a function that returns upstream token storage. This allows lazy access to the storage, which may not be available at middleware creation time.