signer

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package signer signs outbound HTTP requests using AWS Signature Version 4.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HTTPClient

func HTTPClient(s Signer, client *http.Client) *http.Client

HTTPClient copies a client and installs signing without changing its owner. Redirects are disabled by default to avoid signing an untrusted destination. Supply CheckRedirect explicitly to permit trusted redirects; each is re-signed.

Types

type Config

type Config struct {
	Service     string
	Region      string
	Credentials aws.CredentialsProvider
	Clock       func() time.Time
	// DisableURIPathEscaping is needed for S3's single-escaped path convention.
	DisableURIPathEscaping bool
}

Config controls signing without loading the SDK configuration/provider chain. Credentials are retrieved for every request; use aws.CredentialsCache explicitly when provider caching is desired. Callbacks must be safe for concurrent use.

type ConfigError

type ConfigError struct{ Message string }

ConfigError indicates missing signing configuration or environment credentials.

func (*ConfigError) Error

func (e *ConfigError) Error() string

type SigV4Signer

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

SigV4Signer is immutable after construction and safe for concurrent requests.

func New

func New(config Config) (*SigV4Signer, error)

func (*SigV4Signer) Sign

func (s *SigV4Signer) Sign(request *http.Request) (*http.Request, error)

Sign clones headers and URL and returns a request with a replayable body. With GetBody, the input stream is untouched. Otherwise the input body is read and restored; it must not be used concurrently. Callers retain ownership of the input body and must close both requests' bodies when signing standalone. Provider failures and cancellation remain discoverable through errors.Is/As.

type Signer

type Signer interface {
	Sign(*http.Request) (*http.Request, error)
}

Signer separates request signing from sending and permits custom algorithms.

type SigningError

type SigningError struct{ Err error }

SigningError preserves the underlying request conversion or signing failure.

func (*SigningError) Error

func (e *SigningError) Error() string

func (*SigningError) Unwrap

func (e *SigningError) Unwrap() error

type Transport

type Transport struct {
	Signer Signer
	Base   http.RoundTripper
}

Transport signs each round trip, including requests followed by http.Client. It performs no retries. Signer and Base must support concurrent calls.

func (*Transport) RoundTrip

func (t *Transport) RoundTrip(request *http.Request) (*http.Response, error)

Jump to

Keyboard shortcuts

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