oauth

package
v0.30.0 Latest Latest
Warning

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

Go to latest
Published: May 22, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTokenExpirationOutOfRange = errors.New("the KubernetesTokenSourceConfig.TokenExpiration needs to be at least 10m")
	ErrServiceAccountMissing     = errors.New("make sure the ServiceAccount property is set")
)

Functions

func NewKubernetesTokenSource

func NewKubernetesTokenSource(cfg *rest.Config, opts *KubernetesTokenSourceConfig) (*kubernetesTokenSource, error)

Generates a new KubernetesTokenSource which can be used in combination with the golang.org/x/oauth2 package as it implements the https://pkg.go.dev/golang.org/x/oauth2#TokenSource interface.

It will take care of automatically refreshing the credential whenever needed, so that the client that consumes this TokenSource has always an up to date credential available.

Types

type KubernetesTokenSourceConfig

type KubernetesTokenSourceConfig struct {

	// Audiences which should be applied to the generated token.
	Audiences []string

	// ServiceAccount identifies the service account which shall be impersonated when creating the TokenRequest
	ServiceAccount types.NamespacedName

	// Determines how long the credential generated via the TokenRequest API is valid for.
	// Needs to be at least 10 mins. It defaults to 1h.
	TokenExpiration time.Duration
}

Jump to

Keyboard shortcuts

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