auth

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package auth authenticates named broker clients from shared secrets.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrMissing means no usable credential was presented.
	ErrMissing = errors.New("authentication required")
	// ErrInvalid means a credential was presented but matched no client.
	ErrInvalid = errors.New("invalid credentials")
)

Functions

func SecretFromAuthorization

func SecretFromAuthorization(header string) (string, bool)

SecretFromAuthorization extracts a broker secret from Bearer or Basic auth.

Types

type Authenticator

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

Authenticator resolves Authorization headers to named clients.

func New

func New(secrets map[string]string, opts Options) (*Authenticator, error)

New builds an Authenticator from client id to shared secret.

func (*Authenticator) AuthenticateHeader

func (a *Authenticator) AuthenticateHeader(header string) (string, error)

AuthenticateHeader authenticates one raw Authorization header value.

func (*Authenticator) AuthenticateRequest

func (a *Authenticator) AuthenticateRequest(r *http.Request) (string, error)

AuthenticateRequest authenticates the Authorization header from r.

type Options

type Options struct {
	// MinSecretBytes is the minimum accepted client secret length. The default
	// is intentionally modest so existing broker deployments can cut over
	// without weakening production guidance.
	MinSecretBytes int
}

Options configures an Authenticator.

Jump to

Keyboard shortcuts

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