forwarding

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2025 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidCiphertext is returned when ciphertext is invalid or corrupted
	ErrInvalidCiphertext = errors.New("invalid ciphertext")

	// ErrDecryptionFailed is returned when decryption fails
	ErrDecryptionFailed = errors.New("decryption failed")
)
View Source
var (
	// ErrNoFieldsConfigured is returned when no fields are configured for forwarding
	ErrNoFieldsConfigured = errors.New("no fields configured for forwarding")
)

Functions

func GetValueByPath

func GetValueByPath(data map[string]interface{}, path string) string

GetValueByPath retrieves a value from a nested map using a dot-separated path For example, "secrets.access_token" will retrieve data["secrets"]["access_token"] Returns the value as a string if found, empty string otherwise

Types

type Base64Filter

type Base64Filter struct{}

Base64Filter applies base64 encoding

func NewBase64Filter

func NewBase64Filter() *Base64Filter

func (*Base64Filter) Apply

func (f *Base64Filter) Apply(input *FilterOutput) (*FilterOutput, error)

func (*Base64Filter) InputTypes

func (f *Base64Filter) InputTypes() []DataType

func (*Base64Filter) Name

func (f *Base64Filter) Name() string

func (*Base64Filter) OutputType

func (f *Base64Filter) OutputType() DataType

type DataType

type DataType int

DataType represents the type of data (string or binary)

const (
	DataTypeString DataType = iota
	DataTypeBinary
)

type DefaultForwarder

type DefaultForwarder struct {
	// contains filtered or unexported fields
}

DefaultForwarder is the default implementation of Forwarder

func NewForwarder

func NewForwarder(cfg *config.ForwardingConfig, providers []config.OAuth2Provider) *DefaultForwarder

NewForwarder creates a new DefaultForwarder

func (*DefaultForwarder) AddToHeaders

func (f *DefaultForwarder) AddToHeaders(headers http.Header, userInfo *UserInfo) http.Header

AddToHeaders adds user info to HTTP headers Processes each configured field and adds it as an HTTP header

func (*DefaultForwarder) AddToQueryString

func (f *DefaultForwarder) AddToQueryString(targetURL string, userInfo *UserInfo) (string, error)

AddToQueryString adds user info to a URL's query string Processes each configured field and adds it as a query parameter

type EncryptFilter

type EncryptFilter struct {
	// contains filtered or unexported fields
}

EncryptFilter applies AES-256-GCM encryption

func NewEncryptFilter

func NewEncryptFilter(encryptor *Encryptor) *EncryptFilter

func (*EncryptFilter) Apply

func (f *EncryptFilter) Apply(input *FilterOutput) (*FilterOutput, error)

func (*EncryptFilter) InputTypes

func (f *EncryptFilter) InputTypes() []DataType

func (*EncryptFilter) Name

func (f *EncryptFilter) Name() string

func (*EncryptFilter) OutputType

func (f *EncryptFilter) OutputType() DataType

type Encryptor

type Encryptor struct {
	// contains filtered or unexported fields
}

Encryptor handles encryption and decryption of user data

func NewEncryptor

func NewEncryptor(key string) *Encryptor

NewEncryptor creates a new Encryptor with the given key The key is hashed with SHA-256 to ensure it's exactly 32 bytes for AES-256

func (*Encryptor) Decrypt

func (e *Encryptor) Decrypt(ciphertext string) (string, error)

Decrypt decrypts the base64-encoded ciphertext using AES-256-GCM

func (*Encryptor) DecryptMap

func (e *Encryptor) DecryptMap(ciphertext string) (map[string]string, error)

DecryptMap decrypts an encrypted string back to a map of key-value pairs

func (*Encryptor) Encrypt

func (e *Encryptor) Encrypt(plaintext string) (string, error)

Encrypt encrypts the plaintext using AES-256-GCM and returns a base64-encoded string The encrypted data format is: [nonce (12 bytes)][ciphertext]

func (*Encryptor) EncryptMap

func (e *Encryptor) EncryptMap(data map[string]string) (string, error)

EncryptMap encrypts a map of key-value pairs and returns a single encrypted string The map is serialized as JSON before encryption

type Filter

type Filter interface {
	// Name returns the filter name
	Name() string
	// InputTypes returns acceptable input types
	InputTypes() []DataType
	// OutputType returns the output type
	OutputType() DataType
	// Apply applies the filter to the input data
	Apply(input *FilterOutput) (*FilterOutput, error)
}

Filter represents a data transformation filter

type FilterChain

type FilterChain struct {
	// contains filtered or unexported fields
}

FilterChain represents a chain of filters

func NewFilterChain

func NewFilterChain(filterNames []string, encryptor *Encryptor) (*FilterChain, error)

NewFilterChain creates a new filter chain

func (*FilterChain) Apply

func (fc *FilterChain) Apply(input string) (string, error)

Apply applies all filters in the chain

type FilterOutput

type FilterOutput struct {
	Data []byte
	Type DataType
}

FilterOutput holds the result of a filter operation

type Forwarder

type Forwarder interface {
	// AddToHeaders adds user info to HTTP headers
	// Returns a new http.Header with user information added
	AddToHeaders(headers http.Header, userInfo *UserInfo) http.Header

	// AddToQueryString adds user info to a URL's query string
	// Returns the modified URL with user information in query parameters
	AddToQueryString(targetURL string, userInfo *UserInfo) (string, error)
}

Forwarder is the interface for forwarding user information

type UserInfo

type UserInfo struct {
	Username string
	Email    string
	Extra    map[string]interface{} // Additional data from OAuth2 provider
	Provider string                 // OAuth2 provider name
}

UserInfo contains user information to be forwarded

type ZipFilter

type ZipFilter struct{}

ZipFilter applies gzip compression

func NewZipFilter

func NewZipFilter() *ZipFilter

func (*ZipFilter) Apply

func (f *ZipFilter) Apply(input *FilterOutput) (*FilterOutput, error)

func (*ZipFilter) InputTypes

func (f *ZipFilter) InputTypes() []DataType

func (*ZipFilter) Name

func (f *ZipFilter) Name() string

func (*ZipFilter) OutputType

func (f *ZipFilter) OutputType() DataType

Jump to

Keyboard shortcuts

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