credential

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Equal

func Equal(a, b Credential) bool

Types

type AWSCreds

type AWSCreds aws.Credentials

func (*AWSCreds) IsEqual

func (a *AWSCreds) IsEqual(b *AWSCreds) bool

type Credential

type Credential interface {
	// contains filtered or unexported methods
}

Credential is a marker interface for credential types. Implementations include Token, AWSCredentials, and other credential types.

type EventType

type EventType string

EventType represents the type of credential event. It indicates whether a credential is being updated or removed.

const (
	// UpdateEventType indicates that a credential has been updated.
	UpdateEventType EventType = "UPDATE"
	// RemoveEventType indicates that a credential has been removed.
	RemoveEventType EventType = "REMOVE"
)

type Oauth2Creds

type Oauth2Creds oauth2.Token

func (*Oauth2Creds) IsEqual

func (a *Oauth2Creds) IsEqual(b *Oauth2Creds) bool

type Provider

type Provider interface {
	// GetCredentialsWithOptions returns a channel that receives credential results.
	// The channel provides updates when credentials are refreshed or removed.
	// For the first credential and each refresh, an Update event is sent.
	// If credentials are removed, a Remove event is sent.
	// In case of errors, the Err field is populated, Credential is nil, and the refresh loop exits.
	// When the refresh loop exits, the channel is closed.
	// Options can be provided to configure the credentials request.
	GetCredentialsWithOptions(ctx context.Context, opts ...option.Option) (<-chan Result, error)
}

Provider defines the interface for obtaining credentials. It is implemented by all credential providers in the tokenex library.

type Result

type Result struct {
	Credential Credential
	Event      EventType
	Err        error
}

Result encapsulates the credentials received from a credential provider (e.g. cloud providers, k8s etc.) and any error that might occur. When a credential is first obtained or refreshed, Event is set to UpdateEventType. When a credential is removed, Event is set to RemoveEventType. If an error occurs, Err is populated and Credential is set to nil. In case of an error, the credential refresh loop exits, the channel is closed, and it's the caller's responsibility to implement retry logic.

type Token

type Token struct {
	Token     string
	ExpiresAt time.Time
}

func (*Token) IsEqual

func (a *Token) IsEqual(b *Token) bool

type VaultSecret added in v0.2.0

type VaultSecret struct {
	Data map[string]any
}

func (*VaultSecret) IsEqual added in v0.2.0

func (a *VaultSecret) IsEqual(b *VaultSecret) bool

Jump to

Keyboard shortcuts

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