httpauth

package
v0.2.0 Latest Latest
Warning

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

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

Documentation

Overview

Package httpauth contains call-scoped HTTP request authorizers. It depends only on secrets and deliberately does not import the credentials root, keeping the protocol boundary usable by sources and transports alike.

Index

Constants

View Source
const MaxHeaderNameLength = 256

Variables

View Source
var (
	ErrInvalidHeaderName  = errors.New("httpauth: invalid header name")
	ErrInvalidHeaderValue = errors.New("httpauth: invalid header value")
	ErrZeroSecret         = errors.New("httpauth: zero secret")
	ErrNilRequest         = errors.New("httpauth: nil request")
	ErrNilContext         = errors.New("httpauth: nil context")
	ErrCanceled           = errors.New("httpauth: authorization canceled")
)

Functions

This section is empty.

Types

type Authorizer

type Authorizer interface {
	Authorize(context.Context, *http.Request) error
}

Authorizer applies one immutable authority snapshot to one concrete request attempt.

func Bearer

func Bearer(value secrets.Secret) (Authorizer, error)

Bearer constructs an immutable Authorization: Bearer authorizer.

func Header(name string, value secrets.Secret) (Authorizer, error)

Header constructs an immutable authorizer that sets one HTTP field. The authority is copied from Secret.Bytes only at construction, never retained in a caller-owned mutable buffer.

func NewBearer

func NewBearer(value secrets.Secret) (Authorizer, error)

NewBearer is an explicit constructor alias for callers that prefer the New naming convention.

func NewHeader

func NewHeader(name string, value secrets.Secret) (Authorizer, error)

NewHeader is an explicit constructor alias for callers that prefer the conventional New prefix.

func None

func None() Authorizer

None returns an immutable no-op authorizer for explicitly unauthenticated local transports.

type InvalidHeaderNameError

type InvalidHeaderNameError = invalidHeaderNameError

InvalidHeaderNameError reports a malformed HTTP field name without retaining the caller's input.

type InvalidHeaderValueError

type InvalidHeaderValueError = invalidHeaderValueError

InvalidHeaderValueError reports an authority that cannot safely become an HTTP header value.

type NilRequestError

type NilRequestError = nilRequestError

NilRequestError reports an attempt to authorize a nil request.

type ZeroSecretError

type ZeroSecretError = zeroSecretError

ZeroSecretError reports use of an invalid zero secrets.Secret.

Jump to

Keyboard shortcuts

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