openstackiid

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2026 License: AGPL-3.0 Imports: 35 Imported by: 0 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 openstackiid implements the server side of the openstack_iid SPIRE node attestor: it verifies the instance identity token issued by the OpenStack metadata JWT issuer (openstack-spire-issuer) against the issuer's published keys, and turns its claims into the agent's SPIFFE ID and selectors.

The claims are bound to the real instance by the issuer, which authenticates Nova's service token against Keystone and cross-checks the instance and project against the Nova API before signing; this plugin relies on that invariant without being able to enforce it.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrReplayed is returned (wrapped) for a token whose jti was already
	// accepted.
	ErrReplayed = errors.New("token already used")
	// ErrIssuedBeforeStart is returned (wrapped) for a token minted before
	// this plugin process started.
	ErrIssuedBeforeStart = errors.New("token issued before this server started")
	// ErrReplayCacheFull is returned (wrapped) when no token can be
	// recorded: attestations are refused rather than a jti forgotten early.
	ErrReplayCacheFull = errors.New("replay cache full")
)
View Source
var (
	// ErrInvalidToken is returned (wrapped) for a token failing any check.
	ErrInvalidToken = errors.New("invalid token")
	// ErrUnknownKID is returned (wrapped) when no verification key has the
	// token's kid; the caller may re-fetch the JWK Set and try again.
	ErrUnknownKID = errors.New("unknown kid")
)

Functions

func ConfigKeys

func ConfigKeys() []string

ConfigKeys returns the keys plugin_data accepts, a block's keys as "block.key" (the documentation's completeness test reads them).

func SPIFFEID

func SPIFFEID(trustDomain string, c iid.Claims) string

SPIFFEID returns the agent SPIFFE ID for verified claims: spiffe://<trust_domain>/spire/agent/openstack_iid/<project_id>/<instance_id>. Both IDs have been validated, so they are well-formed path segments.

func Selectors

func Selectors(c iid.Claims, allowedTags map[string]bool) []string

Selectors returns the selector values for verified claims. SPIRE infers the selector type from the plugin name, so the values carry no "openstack_iid:" prefix: "project_id:<id>" here is the selector "openstack_iid:project_id:<id>" in registration entries. Tag selectors come in key order; enrichment selectors only when the token carries the claim. Custom claims never become selectors: they are the same for every instance. Tags whose key is not in allowedTags are left out, unless allowedTags is nil (T-3): tags are set by the instance's owner, and the operator decides which of them registration entries may rely on.

func Verify

func Verify(token string, lookup KeyLookup, now time.Time, skew time.Duration) (iid.Header, iid.Claims, error)

Verify checks a compact-serialized openstack_iid token and returns its header and claims: the signature, by the key its kid selects (exactly one key, never trying others), and every claim rule of the shared contract. The tolerance absorbs clock differences between the issuer and this server, so a token is accepted for at most iid.TTL + 2 × skew; it never stretches the lifetime itself (exp - iat <= iid.TTL). Verify is pure: it neither fetches keys nor records anything.

Types

type AuditSyslogConfig

type AuditSyslogConfig struct {
	Enabled  bool   `hcl:"enabled"`
	Socket   string `hcl:"socket"`
	Facility string `hcl:"facility"`
	AppName  string `hcl:"app_name"`
}

AuditSyslogConfig is the audit_syslog block.

type Config

type Config struct {
	JWKSURL                string   `hcl:"jwks_url"`
	JWKSCACertPath         string   `hcl:"jwks_ca_cert_path"`
	TLSMinVersion          string   `hcl:"tls_min_version"`
	JWKSRefreshInterval    string   `hcl:"jwks_refresh_interval"`
	JWKSFetchTimeout       string   `hcl:"jwks_fetch_timeout"`
	JWKSMinRefetchInterval string   `hcl:"jwks_min_refetch_interval"`
	JWKSStaleKeyRetention  string   `hcl:"jwks_stale_key_retention"`
	AllowedProjectIDs      []string `hcl:"allowed_project_ids"`
	ClockSkewTolerance     string   `hcl:"clock_skew_tolerance"`
	// AllowedTagKeys lists the tag keys that become selectors; unset, every
	// tag does (T-3).
	AllowedTagKeys []string `hcl:"allowed_tag_keys"`
	// Reattest is CanReattest (default true; S-4, E-4).
	Reattest *bool `hcl:"reattest"`
	// ReattestAlertWindow is how soon a second attestation of an instance
	// raises an alert (default 5m, 0 disables, at most 1h; S-4, E-1).
	ReattestAlertWindow string `hcl:"reattest_alert_window"`
	// AuditSyslog sends the audit records to syslog too (R-2).
	AuditSyslog *AuditSyslogConfig `hcl:"audit_syslog"`
}

Config is the plugin_data block of the server configuration.

type KeyLookup

type KeyLookup func(kid string) (keystore.PublicKey, bool)

KeyLookup returns the verification key with the given kid.

type Plugin

type Plugin struct {
	nodeattestorv1.UnimplementedNodeAttestorServer
	configv1.UnimplementedConfigServer
	// contains filtered or unexported fields
}

Plugin is the server-side openstack_iid node attestor.

func New

func New() *Plugin

New returns an unconfigured Plugin.

func (*Plugin) Attest

Attest verifies the agent's token and, if it passes every check, returns the agent's SPIFFE ID and selectors, built from the verified claims only.

func (*Plugin) BrokerHostServices

func (p *Plugin) BrokerHostServices(broker pluginsdk.ServiceBroker) error

BrokerHostServices takes SPIRE Server's AgentStore host service, which reattest = false needs: SPIRE leaves trust on first use to the node attestor (S-4, E-4).

func (*Plugin) Configure

Configure validates the plugin_data block and the trust domain, then replaces the configuration and the key source atomically.

func (*Plugin) SetLogger

func (p *Plugin) SetLogger(logger hclog.Logger)

SetLogger routes the plugin's logs, and those of log/slog, to SPIRE.

Jump to

Keyboard shortcuts

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