Help us shape the future of Go! Take the 2026 Go Developer Survey

upstreamswap

package
v0.22.0 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package upstreamswap provides middleware for exchanging embedded auth server access tokens with upstream IdP tokens.

Index

Constants

View Source
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

View Source
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"`

	// ProviderName identifies which upstream provider's tokens to retrieve for injection.
	// This is required and must match a configured upstream provider name.
	ProviderName string `json:"provider_name" yaml:"provider_name"`
}

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.

Jump to

Keyboard shortcuts

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