auth

package
v1.76.0 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2025 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TokenProvider

func TokenProvider(path string, interval time.Duration, logger *zap.Logger) (func() string, error)

TokenProvider creates a token provider that handles file loading and error handling consistently.

func TokenProviderWithTime

func TokenProviderWithTime(path string, interval time.Duration, logger *zap.Logger, timeFn func() time.Time) (func() string, error)

TokenProviderWithTime creates a token provider with injectable time (for testing)

Types

type Method

type Method struct {
	// Scheme is the authentication scheme (e.g., "Bearer")
	Scheme string

	// TokenFn returns the authentication token
	TokenFn func() string

	// FromCtx extracts token from context
	FromCtx func(context.Context) (string, bool)
}

Method represents a single authentication method configuration

type RoundTripper

type RoundTripper struct {
	// Transport is the underlying http.RoundTripper being wrapped. Required.
	Transport http.RoundTripper
	Auths     []Method
}

RoundTripper wraps another http.RoundTripper and injects an authentication header with token into requests.

func (RoundTripper) RoundTrip

func (tr RoundTripper) RoundTrip(r *http.Request) (*http.Response, error)

RoundTrip injects the outbound Authorization header with the token provided in the inbound request.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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