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 ¶
- Variables
- func ConfigKeys() []string
- func SPIFFEID(trustDomain string, c iid.Claims) string
- func Selectors(c iid.Claims, allowedTags map[string]bool) []string
- func Verify(token string, lookup KeyLookup, now time.Time, skew time.Duration) (iid.Header, iid.Claims, error)
- type AuditSyslogConfig
- type Config
- type KeyLookup
- type Plugin
- func (p *Plugin) Attest(stream nodeattestorv1.NodeAttestor_AttestServer) error
- func (p *Plugin) BrokerHostServices(broker pluginsdk.ServiceBroker) error
- func (p *Plugin) Configure(ctx context.Context, req *configv1.ConfigureRequest) (*configv1.ConfigureResponse, error)
- func (p *Plugin) SetLogger(logger hclog.Logger)
Constants ¶
This section is empty.
Variables ¶
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") )
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 ¶
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 ¶
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 Plugin ¶
type Plugin struct {
nodeattestorv1.UnimplementedNodeAttestorServer
configv1.UnimplementedConfigServer
// contains filtered or unexported fields
}
Plugin is the server-side openstack_iid node attestor.
func (*Plugin) Attest ¶
func (p *Plugin) Attest(stream nodeattestorv1.NodeAttestor_AttestServer) error
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 ¶
func (p *Plugin) Configure(ctx context.Context, req *configv1.ConfigureRequest) (*configv1.ConfigureResponse, error)
Configure validates the plugin_data block and the trust domain, then replaces the configuration and the key source atomically.