hmac

package
v0.52.0 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HMACKey

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

func HMACKeyBytes

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

Types

type BearerTokenRoundTripper added in v0.40.0

type BearerTokenRoundTripper struct {
	BearerToken string
	Base        http.RoundTripper
}

func (*BearerTokenRoundTripper) RoundTrip added in v0.40.0

func (t *BearerTokenRoundTripper) RoundTrip(req *http.Request) (*http.Response, error)

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

func (ClientAuth) HTTPClient added in v0.40.0

func (a ClientAuth) HTTPClient() (*http.Client, error)

type ClientConfig added in v0.37.0

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

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"`
}

Jump to

Keyboard shortcuts

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