Help us shape the future of Go! Take the 2026 Go Developer Survey

authentication

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2025 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultExpirationDuration = 5 * time.Minute
)

Variables

This section is empty.

Functions

Types

type ServiceAccountNotFoundError

type ServiceAccountNotFoundError struct {
	ServiceAccountName      string
	ServiceAccountNamespace string
	Err                     error
}

func (*ServiceAccountNotFoundError) Error

Error implements the error interface for ServiceAccountNotFoundError.

func (*ServiceAccountNotFoundError) Unwrap

func (e *ServiceAccountNotFoundError) Unwrap() error

type TokenGetter

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

func NewTokenGetter

func NewTokenGetter(client corev1.ServiceAccountsGetter, options ...TokenGetterOption) *TokenGetter

Returns a token getter that can fetch tokens given a service account. The token getter also caches tokens which helps reduce the number of requests to the API Server. In case a cached token is expiring a fresh token is created.

func (*TokenGetter) Delete

func (t *TokenGetter) Delete(key types.NamespacedName)

func (*TokenGetter) Get

Get returns a token from the cache if available and not expiring, otherwise creates a new token

type TokenGetterOption

type TokenGetterOption func(*TokenGetter)

func WithExpirationDuration

func WithExpirationDuration(expirationDuration time.Duration) TokenGetterOption

type TokenInjectingRoundTripper

type TokenInjectingRoundTripper struct {
	Tripper     http.RoundTripper
	TokenGetter *TokenGetter
	Key         types.NamespacedName
}

func (*TokenInjectingRoundTripper) RoundTrip

func (tt *TokenInjectingRoundTripper) RoundTrip(req *http.Request) (*http.Response, error)

Jump to

Keyboard shortcuts

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