bearertoken

package
v1.45.0 Latest Latest
Warning

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

Go to latest
Published: May 5, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const StoragePropagationKey = "storage.propagate.token"

StoragePropagationKey is a key for viper configuration to pass this option to storage plugins.

Variables

This section is empty.

Functions

func ContextWithBearerToken

func ContextWithBearerToken(ctx context.Context, token string) context.Context

ContextWithBearerToken set bearer token in context.

func GetBearerToken

func GetBearerToken(ctx context.Context) (string, bool)

GetBearerToken from context, or empty string if there is no token.

func PropagationHandler

func PropagationHandler(logger *zap.Logger, h http.Handler) http.Handler

PropagationHandler returns a http.Handler containing the logic to extract the Bearer token from the Authorization header of the http.Request and insert it into request.Context for propagation. The token can be accessed via GetBearerToken.

Types

type RoundTripper

type RoundTripper struct {
	// Transport is the underlying http.RoundTripper being wrapped. Required.
	Transport http.RoundTripper

	// StaticToken is the pre-configured bearer token. Optional.
	StaticToken string

	// OverrideFromCtx enables reading bearer token from Context.
	OverrideFromCtx bool
}

RoundTripper wraps another http.RoundTripper and injects an authentication header with bearer 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.

Jump to

Keyboard shortcuts

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