compatibility

package
v1.0.2 Latest Latest
Warning

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

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

Documentation

Overview

Package compatibility isolates non-RFC 9421 HTTP authentication schemes behind caller-supplied protocol implementations. It does not parse, sign, verify, or reinterpret any legacy wire format itself. Start with an explicit New* adapter and trusted implementation/reporter; shared use requires safe synchronous collaborators. No server/client/worker lifecycle, protocol conformance, reporter-error redaction or automatic authorization is owned.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidAdapter reports incomplete or unsafe adapter configuration.
	ErrInvalidAdapter = errors.New("http signature compatibility: invalid adapter")
	// ErrSigning reports a sanitized external signing failure.
	ErrSigning = errors.New("http signature compatibility: signing failed")
	// ErrVerification reports a sanitized external verification failure.
	ErrVerification = errors.New("http signature compatibility: verification failed")
)

Functions

This section is empty.

Types

type ErrorReporter

type ErrorReporter func(context.Context, Protocol, Operation, error)

ErrorReporter receives the original external implementation failure. It is an application-owned diagnostic boundary and must redact protocol secrets.

type Operation

type Operation string

Operation identifies the compatibility boundary that failed.

const (
	// OperationSign is outbound request signing.
	OperationSign Operation = "sign"
	// OperationVerify is inbound request verification.
	OperationVerify Operation = "verify"
)

type Protocol

type Protocol string

Protocol identifies a compatibility protocol that is deliberately separate from RFC 9421 fields and parsers.

const (
	// CavageDraft identifies the historical Cavage HTTP Signatures drafts.
	CavageDraft Protocol = "cavage-draft"
	// AWSSigV4 identifies AWS Signature Version 4.
	AWSSigV4 Protocol = "aws-sigv4"
	// OAuth1 identifies OAuth 1.0 request signatures.
	OAuth1 Protocol = "oauth1"
)

type SigningRoundTripper

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

SigningRoundTripper applies one explicitly selected legacy or vendor signer to a cloned request before delegating it. It never invokes RFC 9421 parsers. Construct through an explicit New*SigningRoundTripper; zero is not usable. Shared calls require safe borrowed signer/transport/reporter implementations. Reporter panics/blocking are not contained and no client Close is owned.

func NewAWSSigV4SigningRoundTripper

func NewAWSSigV4SigningRoundTripper(config SigningRoundTripperConfig) (*SigningRoundTripper, error)

NewAWSSigV4SigningRoundTripper creates an outbound AWS SigV4 boundary.

func NewCavageSigningRoundTripper

func NewCavageSigningRoundTripper(config SigningRoundTripperConfig) (*SigningRoundTripper, error)

NewCavageSigningRoundTripper creates an outbound Cavage-draft boundary.

func NewOAuth1SigningRoundTripper

func NewOAuth1SigningRoundTripper(config SigningRoundTripperConfig) (*SigningRoundTripper, error)

NewOAuth1SigningRoundTripper creates an outbound OAuth 1.0 boundary.

func NewVendorSigningRoundTripper

func NewVendorSigningRoundTripper(name string, config SigningRoundTripperConfig) (*SigningRoundTripper, error)

NewVendorSigningRoundTripper creates an outbound boundary for one explicitly named vendor scheme. Names use lowercase Structured Field key characters.

func (*SigningRoundTripper) Protocol

func (adapter *SigningRoundTripper) Protocol() Protocol

Protocol returns the explicitly selected compatibility protocol.

func (*SigningRoundTripper) RoundTrip

func (adapter *SigningRoundTripper) RoundTrip(request *http.Request) (*http.Response, error)

RoundTrip implements http.RoundTripper. The caller retains ownership of the original request value; normal RoundTripper body ownership transfers to the configured transport when delegation begins.

type SigningRoundTripperConfig

type SigningRoundTripperConfig struct {
	// Transport is mandatory borrowed transport; normal request-body ownership begins on
	// delegation.
	Transport http.RoundTripper
	// Sign is mandatory caller-implemented protocol signing on an isolated
	// metadata/body-denied view.
	Sign func(context.Context, *http.Request) error
	// ReportError is mandatory synchronous raw diagnostic handling; redact secrets and
	// bound concurrency/blocking.
	ReportError ErrorReporter
}

SigningRoundTripperConfig configures an outbound compatibility adapter. Sign receives an isolated request view. Protocol-specific header and trailer mutations are delegated, except Signature-Input, Signature, and Accept-Signature. Request identity mutations are discarded, and Body cannot be read or closed through the view. Body-derived form state, TLS, and redirect Response graphs are omitted because net/http clones can retain aliases.

type VerificationMiddleware

type VerificationMiddleware func(http.Handler) http.Handler

VerificationMiddleware verifies one explicitly selected non-RFC protocol before invoking the next net/http handler.

func NewAWSSigV4VerificationMiddleware

func NewAWSSigV4VerificationMiddleware(config VerificationMiddlewareConfig) (VerificationMiddleware, error)

NewAWSSigV4VerificationMiddleware creates an inbound AWS SigV4 boundary.

func NewCavageVerificationMiddleware

func NewCavageVerificationMiddleware(config VerificationMiddlewareConfig) (VerificationMiddleware, error)

NewCavageVerificationMiddleware creates an inbound Cavage-draft boundary.

func NewOAuth1VerificationMiddleware

func NewOAuth1VerificationMiddleware(config VerificationMiddlewareConfig) (VerificationMiddleware, error)

NewOAuth1VerificationMiddleware creates an inbound OAuth 1.0 boundary.

func NewVendorVerificationMiddleware

func NewVendorVerificationMiddleware(name string, config VerificationMiddlewareConfig) (VerificationMiddleware, error)

NewVendorVerificationMiddleware creates an inbound boundary for one explicitly named vendor scheme.

type VerificationMiddlewareConfig

type VerificationMiddlewareConfig struct {
	// Verify is mandatory caller protocol verification on an isolated view; only its
	// returned error communicates success.
	Verify func(context.Context, *http.Request) error
	// ReportError receives original external failure synchronously; caller owns
	// redaction, concurrency and panic behavior.
	ReportError ErrorReporter
	// Reject is mandatory application response mapping for a sanitized ErrVerification;
	// no status default is supplied.
	Reject func(http.ResponseWriter, *http.Request, error)
}

VerificationMiddlewareConfig configures an inbound compatibility adapter. Verify receives an isolated request view whose mutations cannot reach later middleware. It communicates verification only through its returned error. Body, body-derived form state, TLS, and redirect Response graphs are omitted from the view. Reject receives only a sanitized error; ReportError is the separate application diagnostic seam.

Jump to

Keyboard shortcuts

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