Documentation
¶
Index ¶
- func IsAudiencesOption(opt option.Option) ([]string, bool)
- func IsClaimsOption(opt option.Option) (map[string]any, bool)
- func IsLifetimeOption(opt option.Option) (time.Duration, bool)
- func NewCredentialsProvider(ctx context.Context, logger logr.Logger) (*credentialsProvider, error)
- func WithAudiences(audiences []string) option.Option
- func WithClaims(claims map[string]any) option.Option
- func WithIdentityTokenProvider(tokenProvider token.IdentityTokenProvider) option.Option
- func WithLifetime(lifetime time.Duration) option.Option
- func WithTracerProvider(tracerProvider trace.TracerProvider) option.Option
- type Credential
- type CredentialsOption
- type CredentialsProvider
- type Provider
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsAudiencesOption ¶
IsAudiencesOption checks if the provided option is an audiences option.
func IsClaimsOption ¶
IsClaimsOption checks if the provided option is a claims option.
func IsLifetimeOption ¶
IsLifetimeOption checks if the provided option is a lifetime option.
func NewCredentialsProvider ¶
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 ¶
WithAudiences sets the audiences for the token.
func WithClaims ¶
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 ¶
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.