pkg

package
v0.0.0-...-bca7abf Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2023 License: CC0-1.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HmacProxyDigest

type HmacProxyDigest struct {
	Name string
	ID   crypto.Hash
}

HmacProxyDigest is a mapping from a hash algorithm name to its ID in the crypto.Hash package, and vice-versa.

type HmacProxyHeaders

type HmacProxyHeaders []string

HmacProxyHeaders defines a []string that can be used with flag.FlagSet.Var() to parse the comma-separated command line values into the slice.

func (*HmacProxyHeaders) Set

func (hph *HmacProxyHeaders) Set(s string) error

Set parses comma-separated values from the input string into the HmacProxyHeaders instance.

func (*HmacProxyHeaders) String

func (hph *HmacProxyHeaders) String() string

String returns a string representation of HmacProxyHeaders.

type HmacProxyMode

type HmacProxyMode int

HmacProxyMode specifies the type of handler to return from NewHTTPProxyHandler.

const (
	// HandlerSignAndProxy for a handler that signs requests before
	// proxying them to an upstream server
	HandlerSignAndProxy HmacProxyMode = iota

	// HandlerAuthAndProxy for a handler that authenticates requests
	// before proxying them to an upstream server
	HandlerAuthAndProxy

	// HandlerAuthForFiles for a handler that will authenticate requests
	// before returning local file system content from -file-root
	HandlerAuthForFiles

	// HandlerAuthOnly for a handler that returns 202 or 401 HTTP status
	// codes after authenticating a request (or not)
	HandlerAuthOnly
)

type HmacProxyOpts

type HmacProxyOpts struct {
	Port       int
	Digest     HmacProxyDigest
	Secret     string
	SignHeader string
	Headers    HmacProxyHeaders
	Mappings   Mappings
	SslCert    string
	SslKey     string
}

HmacProxyOpts contains the parameters needed to determine which authentication handler to launch and to configure it properly.

func (*HmacProxyOpts) Validate

func (opts *HmacProxyOpts) Validate() (err error)

Validate ensures that the HmacProxyOpts configuration is correct and parses some of the values into a useable format. It also sets the Mode member that determines which proxy handler to launch. Collects as many error messages as possible and returns them as a single string via the err return value.

type HmacProxyURL

type HmacProxyURL struct {
	Raw string
	URL *url.URL
}

HmacProxyURL contains a raw URL string from the command line as well as its parsed representation.

type Mappings

type Mappings struct {
	Routes []Route `yaml:"routes,omitempty"`
}

Mappings is a list of paths and the upstream to map them to

type ProxyHandler

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

func NewHTTPProxyHandler

func NewHTTPProxyHandler(opts *HmacProxyOpts) (*ProxyHandler, error)

NewHTTPProxyHandler returns a http.Handler and its description based on the configuration specified in opts.

func (ProxyHandler) ServeHTTP

func (h ProxyHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type Route

type Route struct {
	// Path to math
	Path     string `yaml:"path,omitempty"`
	Upstream string `yaml:"upstream,omitempty"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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