Documentation
¶
Overview ¶
Package spiffe provides interfaces and utilities for SPIFFE URI handling.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DefaultFormatter ¶
type DefaultFormatter struct{}
DefaultFormatter provides standard SPIFFE URI formatting. It generates SPIFFE URIs with optional namespace support based on trust domain configuration.
func (*DefaultFormatter) FormatRoleURI ¶
func (f *DefaultFormatter) FormatRoleURI(trustDomain, domain, role string) string
FormatRoleURI returns a SPIFFE role URI in the format: - With trust domain: spiffe://{trustDomain}/ns/{domain}/ra/{role} - Without trust domain: spiffe://{domain}/ra/{role}
func (*DefaultFormatter) FormatServiceURI ¶
func (f *DefaultFormatter) FormatServiceURI(trustDomain, namespace, domain, service, workloadId string) string
FormatServiceURI returns a SPIFFE service URI in the format: - With trust domain and namespace: spiffe://{trustDomain}/ns/{namespace}/sa/{domain}.{service} - Without trust domain/namespace: spiffe://{domain}/sa/{service} The workloadId parameter is accepted but ignored by the default formatter.
func (*DefaultFormatter) FormatUserURI ¶
func (f *DefaultFormatter) FormatUserURI(trustDomain, namespace, principalName, deviceId string) string
FormatUserURI returns a SPIFFE user URI in the format: spiffe://{trustDomain}/ns/{namespace}/sa/{principalName} The namespace defaults to "default" if not specified. The deviceId parameter is accepted but ignored by the default formatter.
type DefaultParser ¶
type DefaultParser struct{}
DefaultParser provides standard SPIFFE URI parsing. It parses both standard and namespaced SPIFFE URIs.
func (*DefaultParser) ParseCAURI ¶
func (p *DefaultParser) ParseCAURI(uri string) (string, string, string)
ParseCAURI parses a SPIFFE CA URI and returns its components. Returns (trustDomain, namespace, caName) or ("", "", "") if not a valid CA URI.
func (*DefaultParser) ParseRoleURI ¶
func (p *DefaultParser) ParseRoleURI(uri string) (string, string)
ParseRoleURI parses a SPIFFE role URI and returns domain and role.
func (*DefaultParser) ParseServiceURI ¶
ParseServiceURI parses a SPIFFE service URI and returns its components. Returns (trustDomain, namespace, domain, service, workloadId) for full URIs, or ("", "", domain, service, "") for basic URIs. The default parser always returns an empty string for workloadId.
type URIFormatter ¶
type URIFormatter interface {
// FormatServiceURI returns a SPIFFE service URI given trust domain, namespace, domain, service name, and optional workload ID.
// The workloadId parameter is provided for custom implementations that need it; the default formatter ignores it.
FormatServiceURI(trustDomain, namespace, domain, service, workloadId string) string
// FormatRoleURI returns a SPIFFE role URI given trust domain, domain, and role name.
FormatRoleURI(trustDomain, domain, role string) string
// FormatUserURI returns a SPIFFE user URI given trust domain, namespace, principal name, and optional device ID.
// The deviceId parameter is provided for custom implementations that need it; the default formatter ignores it.
FormatUserURI(trustDomain, namespace, principalName, deviceId string) string
}
URIFormatter defines custom SPIFFE URI formatting behavior for CSR generation. Implementations can override the default SPIFFE URI format (e.g., for custom trust domains or namespaces). Implementations of this interface can be provided via options or set as the default formatter.
func GetDefaultFormatter ¶
func GetDefaultFormatter() URIFormatter
GetDefaultFormatter returns the current default SPIFFE URI formatter. Returns a DefaultFormatter instance.
type URIParser ¶
type URIParser interface {
// ParseServiceURI parses a SPIFFE service URI and returns its components including an optional workload ID.
// The workloadId will always be empty string for the default parser.
ParseServiceURI(uri string) (trustDomain, namespace, domain, service, workloadId string)
ParseRoleURI(uri string) (domain, role string)
ParseCAURI(uri string) (trustDomain, namespace, caName string)
}
URIParser defines SPIFFE URI parsing behavior.
func GetDefaultParser ¶
func GetDefaultParser() URIParser
GetDefaultParser returns the current default SPIFFE URI parser. Returns a DefaultParser instance.