auth

package
v0.5.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetRegisteredRoundTripperFactoryInitializers

func GetRegisteredRoundTripperFactoryInitializers() map[AuthType]RoundTripperFactoryInitFunc

func GetRoundTripper

func GetRoundTripper(c *ClientAuth, next http.RoundTripper,
	initializers map[AuthType]RoundTripperFactoryInitFunc,
) (http.RoundTripper, error)

func RegisterRoundTripperInitializer

func RegisterRoundTripperInitializer(authType AuthType, initFunc RoundTripperFactoryInitFunc)

RegisterRoundTripperInitializer registers a authRoundTripper initializer function for a specific prometheus AuthType, the function will be called when the prometheus client is created. The function should return a RoundTripperFactory for the prometheus AuthType. If the function is called multiple times for the same AuthType, the last one will be used.

Types

type AuthType

type AuthType string
const (
	BasicAuth       AuthType = "Basic"
	BearerTokenAuth AuthType = "BearerToken"
)

type ClientAuth

type ClientAuth struct {
	Type        string
	Username    string
	BearerToken string
	Password    string
}

ClientAuth holds the HTTP client identity info.

type RoundTripperFactory

type RoundTripperFactory interface {
	GetAuthRoundTripper(c *ClientAuth) (http.RoundTripper, error)
}

func NewBasicAuthRoundTripperProvider

func NewBasicAuthRoundTripperProvider(next http.RoundTripper) (RoundTripperFactory, error)

func NewTokenAuthRoundTripperProvider

func NewTokenAuthRoundTripperProvider(next http.RoundTripper) (RoundTripperFactory, error)

type RoundTripperFactoryInitFunc

type RoundTripperFactoryInitFunc func(next http.RoundTripper) (RoundTripperFactory, error)

RoundTripperFactoryInitFunc is the function to initialize a authRoundTripper

Jump to

Keyboard shortcuts

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