leasehttp

package
v0.1.0-alpha.14 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2026 License: Apache-2.0 Imports: 17 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package leasehttp provides authenticated HTTPS access to one controller member's lease records.

It uses strict JSON and mTLS. Certificate signing, Authority.Grant, and leader election remain outside the handler.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrHTTPSRequired reports invalid HTTPS configuration or an untrusted server connection.
	ErrHTTPSRequired = errors.New("meldbase lease HTTP: verified HTTPS is required")
	// ErrProtocol reports invalid lease protocol data or responses.
	ErrProtocol = errors.New("meldbase lease HTTP: invalid protocol response")
)

Functions

This section is empty.

Types

type Authorize

type Authorize = replicationauth.Authorize

Authorize maps a verified peer certificate to a trusted controller identity.

The identity must not come from a lease frame or URL.

func NewMTLSAuthorizer

func NewMTLSAuthorizer(config MTLSConfig) (Authorize, error)

NewMTLSAuthorizer creates an authorizer for verified and configured client certificates.

type Client

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

Client reads and conditionally updates one controller member's lease records over verified HTTPS.

It implements primarylease.LeaseStore. QuorumStore handles majority decisions across several clients.

func NewClient

func NewClient(options ClientOptions) (*Client, error)

NewClient creates a client with validated server pins and HTTP redirects disabled.

func (*Client) CompareAndSwapPrimaryLease

func (client *Client) CompareAndSwapPrimaryLease(ctx context.Context, databaseID [16]byte, previous *primarylease.LeaseRecord, next primarylease.LeaseRecord) (bool, error)

CompareAndSwapPrimaryLease asks a member to replace a lease matching the expected state.

func (*Client) LoadPrimaryLease

func (client *Client) LoadPrimaryLease(ctx context.Context, databaseID [16]byte) (primarylease.LeaseRecord, bool, error)

LoadPrimaryLease fetches and validates a member's lease record.

func (*Client) PrimaryLeaseMemberIdentities

func (client *Client) PrimaryLeaseMemberIdentities() []string

PrimaryLeaseMemberIdentities exposes every expected, verified server leaf fingerprint to primarylease.QuorumStore.

The returned copy is canonical and cannot mutate the client's identity configuration.

func (*Client) PrimaryLeaseMemberIdentity

func (client *Client) PrimaryLeaseMemberIdentity() string

PrimaryLeaseMemberIdentity retains the legacy single-identity method.

New callers must use PrimaryLeaseMemberIdentities so certificate rotation cannot hide an overlapping member identity.

type ClientOptions

type ClientOptions struct {
	Endpoint string
	// ExpectedServerFingerprint is the legacy single-leaf configuration. New
	// deployments should use ExpectedServerFingerprints so an old and a new
	// leaf can overlap during a controlled rotation. The two fields are mutually
	// exclusive.
	ExpectedServerFingerprint string
	// ExpectedServerFingerprints is one to four lowercase SHA-256 server leaf
	// fingerprints. Every configured leaf identifies the same static quorum
	// member; QuorumStore rejects an overlap with another replica's pin set.
	ExpectedServerFingerprints []string
	HTTPClient                 *http.Client
}

ClientOptions sets one controller member's endpoint, expected certificates, and HTTP client.

HTTPClient should carry the caller's mTLS certificate and trusted server roots. The endpoint cannot include a path, query, userinfo or fragment, preventing URL-controlled routing ambiguity.

type MTLSConfig

type MTLSConfig = replicationauth.MTLSConfig

MTLSConfig maps verified peer certificate fingerprints to trusted identities.

type Member

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

Member serves authenticated lease record reads and conditional writes over HTTP.

func NewMember

func NewMember(config MemberConfig) (*Member, error)

NewMember creates a lease member handler with a store and peer authorizer.

func (*Member) ServeHTTP

func (member *Member) ServeHTTP(writer http.ResponseWriter, request *http.Request)

ServeHTTP authenticates a peer and routes its lease read or conditional write.

type MemberConfig

type MemberConfig struct {
	Store     primarylease.LeaseStore
	Authorize Authorize
}

MemberConfig sets one controller member's lease store and peer authorization rules.

The enclosing server must require and verify client certificates; Authorize maps the verified leaf certificate to a configured controller identity.

Jump to

Keyboard shortcuts

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