hmac

package
v0.37.4 Latest Latest
Warning

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

Go to latest
Published: May 3, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	EmptyClientConfig = ClientConfig{}
	EmptyServerConfig = ServerConfig{}
)

Functions

func HMACKey

func HMACKey(sharedKey, data []byte) (string, error)

func HMACKeyBytes

func HMACKeyBytes(sharedKey, data []byte) ([]byte, error)

Types

type ClientAuth added in v0.37.0

type ClientAuth struct {
	Config ClientConfig
}

func (ClientAuth) AddAuth added in v0.37.0

func (a ClientAuth) AddAuth(req *http.Request) error

AddAuth adds the HMAC token to the request as a bearer token

TODO: This should be refactored to use the request Body to calculate the digest /token

type ClientConfig added in v0.37.0

type ClientConfig struct {
	CommonConfig `mapstructure:",squash"`
}

func (ClientConfig) IsEmpty added in v0.37.0

func (c ClientConfig) IsEmpty() bool

type CommonConfig added in v0.37.0

type CommonConfig struct {
	AllowInsecureHTTP bool `mapstructure:"allow-insecure-http"`
	// Inline shared key used to HMAC with value from HTTPHeader
	SharedKey string `mapstructure:"shared-key"`
	// Path to read shared key from
	SharedKeyPath string `mapstructure:"shared-key-path"`
	Data          string `mapstructure:"data"`
}

type Handler added in v0.37.0

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

func NewHandler added in v0.37.0

func NewHandler(cfg ServerConfig) *Handler

func (*Handler) AuthRequest added in v0.37.0

func (a *Handler) AuthRequest(r *http.Request) (stdcontext.Context, error)

func (*Handler) Wrap added in v0.37.0

func (a *Handler) Wrap(handler http.Handler) http.Handler

type ServerConfig added in v0.37.0

type ServerConfig struct {
	CommonConfig `mapstructure:",squash"`
	// HTTP Header to use as data input
	PrincipalHeader string `mapstructure:"principal-header"`
}

func (ServerConfig) IsEmpty added in v0.37.0

func (c ServerConfig) IsEmpty() bool

Jump to

Keyboard shortcuts

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