broker

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package broker is the only path from a stored credential to an authenticated request. It checks authorization and state, unseals the credential, and returns an HTTP client that authenticates each request and may reach only the provider's hosts. Callers never receive the credential.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Broker

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

Broker hands out authenticated clients.

func New

func New(o Options) (*Broker, error)

New returns a broker.

func (*Broker) HTTPClient

func (b *Broker) HTTPClient(ctx context.Context, owner cf.OwnerID, p cf.Principal, connID string, use cf.Use) (*http.Client, error)

HTTPClient returns a client whose requests carry the connection's credential. The principal must be allowed to use the connection, and the connection must be connected. The credential is read once, when the client is made: make a client per unit of work, so a disconnect or a refresh applies to the next one.

func (*Broker) ProviderClient

func (b *Broker) ProviderClient(m provider.Manifest) (*http.Client, error)

ProviderClient returns an unauthenticated client restricted to the manifest's hosts, for validation.

func (*Broker) Seal

Seal encrypts material as version v of c's credential.

func (*Broker) Unseal

func (b *Broker) Unseal(ctx context.Context, c cf.Connection) (provider.Material, error)

Unseal reads and decrypts c's active credential. Any failure is cf.ErrCredentialUnavailable: there is no fallback.

type Options

type Options struct {
	Store      cf.Store         // required
	Crypto     cf.Cryptographer // required
	Providers  *provider.Registry
	Authorizer cf.Authorizer // required
	// Auditor records refusals. Optional.
	Auditor cf.Auditor
	// Egress is the policy template; its Hosts are replaced by each
	// provider's manifest hosts.
	Egress egress.Policy
	// OnUse, if set, is called for each client handed out, for use counters.
	OnUse func(ctx context.Context, c cf.Connection, u cf.Use)
	Clock cf.Clock
}

Options configures a Broker.

Jump to

Keyboard shortcuts

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