upstreamswap

package
v0.11.3 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2026 License: Apache-2.0 Imports: 12 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"`
}

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 RefresherGetter added in v0.11.3

type RefresherGetter func() storage.UpstreamTokenRefresher

RefresherGetter is a function that returns an upstream token refresher. This allows lazy access to the refresher, which may not be available at middleware creation time.

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.

Jump to

Keyboard shortcuts

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