generic

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsAudiencesOption

func IsAudiencesOption(opt option.Option) ([]string, bool)

IsAudiencesOption checks if the provided option is an audiences option.

func IsClaimsOption

func IsClaimsOption(opt option.Option) (map[string]any, bool)

IsClaimsOption checks if the provided option is a claims option.

func IsLifetimeOption

func IsLifetimeOption(opt option.Option) (time.Duration, bool)

IsLifetimeOption checks if the provided option is a lifetime option.

func NewCredentialsProvider

func NewCredentialsProvider(ctx context.Context, logger logr.Logger) (*credentialsProvider, error)

NewCredentialsProvider creates a new instance of CredentialsProvider for generic token handling. The returned provider simply passes through tokens from the identity token provider and refreshes them before expiration. This provider is useful when you just need to use tokens directly from an identity provider without exchanging them.

Parameters:

  • ctx: The context for the operation
  • logger: Logger for logging credential operations

Returns:

  • A credential provider that passes through tokens from the identity token provider
  • An error if the provider cannot be created

func WithAudiences

func WithAudiences(audiences []string) option.Option

WithAudiences sets the audiences for the token.

func WithClaims

func WithClaims(claims map[string]any) option.Option

WithClaims sets additional claims to be included in the token.

func WithIdentityTokenProvider

func WithIdentityTokenProvider(tokenProvider token.IdentityTokenProvider) option.Option

WithIdentityTokenProvider sets the id token provider.

func WithLifetime

func WithLifetime(lifetime time.Duration) option.Option

WithLifetime sets the lifetime duration for the token.

func WithTracerProvider added in v0.4.0

func WithTracerProvider(tracerProvider trace.TracerProvider) option.Option

WithTracerProvider sets the OTel TracerProvider used to emit credential.fetch spans. If not set, the tracer falls back to the current span's TracerProvider (if any), then the OTel global TracerProvider.

Types

type Credential

type Credential = credential.Result

type CredentialsOption

type CredentialsOption interface {
	Apply(*credentialsConfig)
}

Option is a function that modifies the credentialsConfig.

type CredentialsProvider

type CredentialsProvider interface {
	// GetCredentials returns a channel that receives the tokens from the provided token provider.
	// The channel provides updates when tokens are refreshed or removed.
	// For the first token and each refresh, an Update 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.
	// The tokenProvider is used to obtain the tokens.
	// Options can be provided to configure the token provider.
	GetCredentials(ctx context.Context, tokenProvider token.IdentityTokenProvider, opts ...option.Option) (<-chan Credential, error)
}

CredentialsProvider defines the interface for obtaining generic credentials. It simply returns the token provided by the identity token provider and refreshes it before expiration. This provider is useful when you just need to pass through tokens from an identity provider.

type Provider

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

Jump to

Keyboard shortcuts

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