spiffe

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package spiffe integrates rotating X.509 identities from the SPIFFE Workload API.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IDFromContext

func IDFromContext(ctx context.Context) (string, bool)

IDFromContext returns the verified peer SPIFFE ID from gRPC transport credentials.

func Parse

func Parse(raw string) (string, error)

Parse parses and validates an identifier.

func PeerID

func PeerID(state tls.ConnectionState) (string, bool)

PeerID returns the verified SPIFFE ID from a mutual TLS connection state.

Types

type Config

type Config struct {
	Socket, TrustDomain, ExpectedID string
	AllowedPeers                    []string
	Authorize                       func(string) bool
	AllowTrustDomain                bool
	Timeout                         time.Duration
}

Config contains explicit constructor settings; see package documentation for defaults.

func FromEnv

func FromEnv() (Config, bool, error)

FromEnv reads GRPC_SECURITY_MODE, SPIFFE_* and APP_SPIFFE_* variables used by Staypace Cloud services. enabled is true when GRPC_SECURITY_MODE=spire or APP_ENABLE_SPIFFE=true. Call New only when enabled.

type Source

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

Source owns a rotating SPIFFE Workload API identity and peer authorization policy.

func New

func New(ctx context.Context, c Config) (*Source, error)

New constructs and validates an explicitly owned instance. See package documentation for defaults and cleanup.

func (*Source) Allows

func (s *Source) Allows(peer string) bool

Allows reports whether the peer SPIFFE ID satisfies the configured authorization policy.

func (*Source) ClientTLS

func (s *Source) ClientTLS() *tls.Config

ClientTLS builds a rotating, authorized mutual TLS client configuration.

func (*Source) Close

func (s *Source) Close() error

Close releases owned resources. See package documentation for shutdown ordering.

func (*Source) GetX509SVID

func (s *Source) GetX509SVID() (*x509svid.SVID, error)

GetX509SVID supplies the current identity to TLS while rechecking configured identity constraints after rotation.

func (*Source) Identity

func (s *Source) Identity() (string, error)

Identity returns the currently validated workload SPIFFE ID.

func (*Source) ServerTLS

func (s *Source) ServerTLS() *tls.Config

ServerTLS builds a rotating, authorized mutual TLS server configuration.

Jump to

Keyboard shortcuts

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