roundtrippers

package
v0.0.0-...-6a0d788 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2022 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DebugBodyChunkLength = 100

Functions

func NewAuthProxyRoundTripper

func NewAuthProxyRoundTripper(username string, groups []string, extra map[string][]string, rt http.RoundTripper) http.RoundTripper

NewAuthProxyRoundTripper provides a roundtripper which will add auth proxy fields to requests for authentication terminating proxy cases assuming you pull the user from the context: username is the user.Info.GetName() of the user groups is the user.Info.GetGroups() of the user extra is the user.Info.GetExtra() of the user extra can contain any additional information that the authenticator thought was interesting, for example authorization scopes. In order to faithfully round-trip through an impersonation flow, these keys MUST be lowercase.

func NewBasicAuthRoundTripper

func NewBasicAuthRoundTripper(username, password string, rt http.RoundTripper) http.RoundTripper

NewBasicAuthRoundTripper will apply a BASIC auth authorization header to a request unless it has already been set.

func NewBearerAuthRoundTripper

func NewBearerAuthRoundTripper(bearer string, rt http.RoundTripper) http.RoundTripper

NewBearerAuthRoundTripper adds the provided bearer token to a request unless the authorization header has already been set.

func NewBearerAuthWithRefreshRoundTripper

func NewBearerAuthWithRefreshRoundTripper(bearer string, tokenFile string, rt http.RoundTripper) (http.RoundTripper, error)

NewBearerAuthWithRefreshRoundTripper adds the provided bearer token to a request unless the authorization header has already been set. If tokenFile is non-empty, it is periodically read, and the last successfully read content is used as the bearer token. If tokenFile is non-empty and bearer is empty, the tokenFile is read immediately to populate the initial bearer token.

func NewCachedFileTokenSource

func NewCachedFileTokenSource(path string) *cachingTokenSource

NewCachedFileTokenSource returns a resettable token source which reads a token from a file at a specified path and periodically reloads it.

func NewCachedTokenSource

func NewCachedTokenSource(ts oauth2.TokenSource) *cachingTokenSource

NewCachedTokenSource returns resettable token source with caching. It reads a token from a designed TokenSource if not in cache or expired.

func NewDebuggingRoundTripper

func NewDebuggingRoundTripper(log logr.Logger, rt http.RoundTripper) http.RoundTripper

NewDebuggingRoundTripper allows to display in the logs output debug information on the API requests performed by the client.

func NewGzipHeaderRoundTripper

func NewGzipHeaderRoundTripper(rt http.RoundTripper) http.RoundTripper

NewGzipHeaderRoundTripper

func NewRequestClonerRoundTripper

func NewRequestClonerRoundTripper(rt http.RoundTripper) http.RoundTripper

func NewUserAgentRoundTripper

func NewUserAgentRoundTripper(userAgent string, rt http.RoundTripper) http.RoundTripper

NewUserAgentRoundTripper will add User-Agent header to a request unless it has already been set.

func ResettableTokenSourceWrapTransport

func ResettableTokenSourceWrapTransport(ts ResettableTokenSource) func(http.RoundTripper) http.RoundTripper

ResettableTokenSourceWrapTransport returns a WrapTransport that injects bearer tokens authentication from an ResettableTokenSource.

func SetAuthProxyHeaders

func SetAuthProxyHeaders(req *http.Request, username string, groups []string, extra map[string][]string)

SetAuthProxyHeaders stomps the auth proxy header fields. It mutates its argument.

func TokenSourceWrapTransport

func TokenSourceWrapTransport(ts oauth2.TokenSource) func(http.RoundTripper) http.RoundTripper

TokenSourceWrapTransport returns a WrapTransport that injects bearer tokens authentication from an oauth2.TokenSource.

Types

type DynamicTransportTripper

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

func NewDynamicTransportTripper

func NewDynamicTransportTripper() *DynamicTransportTripper

func (*DynamicTransportTripper) CloseIdleConnections

func (rt *DynamicTransportTripper) CloseIdleConnections()

func (*DynamicTransportTripper) RegisterTransportCreator

func (rt *DynamicTransportTripper) RegisterTransportCreator(fn TransportCreator)

func (*DynamicTransportTripper) RegisterTransportUpdater

func (rt *DynamicTransportTripper) RegisterTransportUpdater(fn TransportUpdater)

func (*DynamicTransportTripper) RoundTrip

func (rt *DynamicTransportTripper) RoundTrip(req *http.Request) (*http.Response, error)

func (*DynamicTransportTripper) WrappedRoundTripper

func (rt *DynamicTransportTripper) WrappedRoundTripper() http.RoundTripper

type ResettableTokenSource

type ResettableTokenSource interface {
	oauth2.TokenSource
	ResetTokenOlderThan(time.Time)
}

type RoundTripperWrapper

type RoundTripperWrapper interface {
	http.RoundTripper
	WrappedRoundTripper() http.RoundTripper
}

type TransportCreator

type TransportCreator func(transport *http.Transport, isClone bool) (*http.Transport, bool, error)

type TransportUpdater

type TransportUpdater func(req *http.Request, transport *http.Transport, isClone bool) (*http.Transport, error)

Jump to

Keyboard shortcuts

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