Help us shape the future of Go! Take the 2026 Go Developer Survey

targetenrollment

package
v0.4.23 Latest Latest
Warning

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

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

Documentation

Overview

Package targetenrollment binds one-use enrollment to an existing Core issuer.

Index

Constants

View Source
const (
	AuthorizationPath        = "/api/v1/connectors/authorizations"
	RenewalAuthorizationPath = "/api/v1/connectors/renewal-authorizations"
	EnrollmentPath           = "/api/v1/connectors/enroll"
)

Variables

View Source
var ErrDenied = errors.New("enrollment authorization is invalid, expired, or consumed")

Functions

func AdmitTLSNode

func AdmitTLSNode(ctx context.Context, state tls.ConnectionState, scope Scope, registry NodeRegistry) error

AdmitTLSNode must be called after a server-side RequireAndVerifyClientCert TLS 1.3 handshake and again when binding Hello/capabilities to the Core scope. It does not advertise a capability or execute a runtime request.

func NormalizeCertificateSerial

func NormalizeCertificateSerial(serial string) (string, error)

Types

type Authority

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

func New

func New(store Store, issuer serviceaccess.CSRIssuer) (*Authority, error)

func (*Authority) Create

func (a *Authority) Create(ctx context.Context, scope Scope, lifetime, certificateTTL time.Duration) (Bootstrap, error)

func (*Authority) CreateRenewal

func (a *Authority) CreateRenewal(ctx context.Context, scope Scope, lifetime, certificateTTL time.Duration) (Bootstrap, error)

func (*Authority) Enroll

func (a *Authority) Enroll(ctx context.Context, request Request) (Result, error)

type Bootstrap

type Bootstrap struct {
	Token     string    `json:"token"`
	Nonce     string    `json:"nonce"`
	ExpiresAt time.Time `json:"expires_at"`
}

type CurrentNodeTrust

type CurrentNodeTrust interface {
	NodeTrust(context.Context) (*x509.CertPool, error)
}

CurrentNodeTrust is consulted for active sessions as well as new admission. Handshake-time VerifiedChains alone cannot detect removal of a former CA.

type Grant

type Grant struct {
	Scope          Scope
	TokenDigest    string
	NonceDigest    string
	ExpiresAt      time.Time
	CertificateTTL time.Duration
}

Grant contains only digests, never the bootstrap bearer credential or nonce.

type HTTPHandler

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

func NewHTTP

func NewHTTP(authority *Authority, resolve ScopeResolver) (*HTTPHandler, error)

func (*HTTPHandler) ServeHTTP

func (h *HTTPHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type NodeRegistry

type NodeRegistry interface {
	AdmitCertificate(context.Context, Scope, string, time.Time) error
}

NodeRegistry admits only a currently active certificate bound to the exact persisted tenant/Target/node/runtime. A trusted CA alone is not admission.

func WithLiveTrust

func WithLiveTrust(registry NodeRegistry, load func(context.Context) (*x509.CertPool, error)) (NodeRegistry, error)

WithLiveTrust keeps persisted certificate admission and current CA trust as independent requirements. Neither a trusted CA nor an active row is enough.

type RenewalStore

type RenewalStore interface {
	CreateRenewal(context.Context, Grant) error
}

RenewalStore explicitly authorizes replacement of an existing node's active certificate. Ordinary initial enrollment cannot replace an issued identity.

type Request

type Request struct {
	Scope  Scope
	Token  string
	Nonce  string
	CSRPEM []byte
}

type Result

type Result struct {
	Certificate serviceaccess.IssuedCertificate
	Trust       serviceaccess.TrustBundle
}

type Scope

type Scope struct {
	TenantID string
	TargetID string
	NodeID   string
	Runtime  string
}

Scope is selected and authorized by Core before creating a bootstrap grant. The Connector cannot choose another tenant, Target, runtime, or identity.

func (Scope) Identity

func (s Scope) Identity() string

func (Scope) Validate

func (s Scope) Validate() error

type ScopeResolver

type ScopeResolver func(context.Context, string, string, string) (Scope, error)

ScopeResolver must use Core's Target registry, tenant ownership and effective policy. User-supplied runtime and tenant fields are deliberately not accepted.

type Store

type Store interface {
	Create(context.Context, Grant) error
	Consume(context.Context, Scope, string, string, string, time.Time) (Grant, error)
	RecordIssued(context.Context, Scope, string, string, time.Time) error
}

Store must persist consumption before returning success, including under concurrent requests and process restarts. Signing failures do not unconsume.

Jump to

Keyboard shortcuts

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