spiffeid

package
v2.0.0-beta.6 Latest Latest
Warning

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

Go to latest
Published: May 25, 2021 License: Apache-2.0 Imports: 5 Imported by: 317

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Join

func Join(trustDomain string, segments ...string) (string, error)

Join returns the string representation of an ID inside the given trust domain (e.g. example.org) with the given path segments. An error is returned if the trust domain is not valid (see TrustDomainFromString).

func MustJoin

func MustJoin(trustDomain string, segments ...string) string

MustJoin returns the string representation of an ID inside the given trust domain (e.g. example.org) with the given path segments. The function panics if the trust domain is not valid (see TrustDomainFromString).

Types

type ID

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

ID is a SPIFFE ID

func FromString

func FromString(s string) (ID, error)

FromString parses a SPIFFE ID from a string.

func FromURI

func FromURI(uri *url.URL) (ID, error)

FromURI parses a SPIFFE ID from a URI.

func Must

func Must(trustDomain string, segments ...string) ID

Must creates a new ID using the trust domain (e.g. example.org) and path segments. The function panics if the trust domain is not valid (see TrustDomainFromString).

func New

func New(trustDomain string, segments ...string) (ID, error)

New creates a new ID using the trust domain (e.g. example.org) and path segments. The resulting path after joining the segments is normalized according to the rules of the standard path.Join() function. An error is returned if the trust domain is not valid (see TrustDomainFromString).

func RequireFromString

func RequireFromString(s string) ID

RequireFromString is similar to FromString except that instead of returning an error on malformed input, it panics. It should only be used when given string is statically verifiable.

func RequireFromURI

func RequireFromURI(uri *url.URL) ID

RequireFromURI is similar to FromURI except that instead of returning an error on malformed input, it panics. It should only be used when given string is statically verifiable.

func (ID) IsZero

func (id ID) IsZero() bool

IsZero returns true if the SPIFFE ID is the zero value.

func (ID) MemberOf

func (id ID) MemberOf(td TrustDomain) bool

MemberOf returns true if the SPIFFE ID is a member of the given trust domain.

func (ID) Path

func (id ID) Path() string

Path returns the path of the SPIFFE ID inside the trust domain.

func (ID) String

func (id ID) String() string

String returns the string representation of the SPIFFE ID, e.g., "spiffe://example.org/foo/bar".

func (ID) TrustDomain

func (id ID) TrustDomain() TrustDomain

TrustDomain returns the trust domain of the SPIFFE ID.

func (ID) URL

func (id ID) URL() *url.URL

URL returns a URL for SPIFFE ID.

type Matcher

type Matcher func(ID) error

Matcher is used to match a SPIFFE ID.

func MatchAny

func MatchAny() Matcher

MatchAny matches any SPIFFE ID.

func MatchID

func MatchID(expected ID) Matcher

MatchID matches a specific SPIFFE ID.

func MatchMemberOf

func MatchMemberOf(expected TrustDomain) Matcher

MatchMemberOf matches any SPIFFE ID in the given trust domain.

func MatchOneOf

func MatchOneOf(expected ...ID) Matcher

MatchOneOf matches any SPIFFE ID in the given list of IDs.

type TrustDomain

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

TrustDomain is the name of a SPIFFE trust domain (e.g. example.org).

func RequireTrustDomainFromString

func RequireTrustDomainFromString(s string) TrustDomain

RequireTrustDomainFromString is similar to TrustDomainFromString except that instead of returning an error on malformed input, it panics. It should only be used when given string is statically verifiable.

func RequireTrustDomainFromURI

func RequireTrustDomainFromURI(uri *url.URL) TrustDomain

RequireTrustDomainFromURI is similar to TrustDomainFromURI except that instead of returning an error on malformed input, it panics. It should only be used when the given URI is statically verifiable.

func TrustDomainFromString

func TrustDomainFromString(s string) (TrustDomain, error)

TrustDomainFromString returns a new TrustDomain from a string. The string can either be the host part of a URI authority component (e.g. example.org), or a valid SPIFFE ID URI (e.g. spiffe://example.org), otherwise an error is returned. The trust domain is normalized to lower case.

func TrustDomainFromURI

func TrustDomainFromURI(uri *url.URL) (TrustDomain, error)

TrustDomainFromURI returns a new TrustDomain from a URI. The URI must be a valid SPIFFE ID (see FromURI) or an error is returned. The trust domain is extracted from the host field and normalized to lower case.

func (TrustDomain) Compare

func (td TrustDomain) Compare(other TrustDomain) int

Compare returns an integer comparing the trust domain to another lexicographically. The result will be 0 if td==other, -1 if td < other, and +1 if td > other.

func (TrustDomain) ID

func (td TrustDomain) ID() ID

ID returns the SPIFFE ID of the trust domain.

func (TrustDomain) IDString

func (td TrustDomain) IDString() string

IDString returns a string representation of the the SPIFFE ID of the trust domain, e.g. "spiffe://example.org".

func (TrustDomain) IsZero

func (td TrustDomain) IsZero() bool

IsZero returns true if the trust domain is the zero value.

func (TrustDomain) NewID

func (td TrustDomain) NewID(path string) ID

NewID returns a SPIFFE ID with the given path inside the trust domain.

func (TrustDomain) String

func (td TrustDomain) String() string

String returns the trust domain as a string, e.g. example.org.

Jump to

Keyboard shortcuts

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