auth

package
v1.101.0 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BasicAuthConfig

type BasicAuthConfig struct {
	Username     string
	Password     string
	PasswordFile string
}

BasicAuthConfig represents basic auth config.

type Config

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

Config is auth config.

func Generate

func Generate(filterOptions ...ConfigOptions) (*Config, error)

Generate returns Config based on the given params

func (*Config) GetAuthHeader

func (ac *Config) GetAuthHeader() string

GetAuthHeader returns optional `Authorization: ...` http header.

func (*Config) SetHeaders

func (ac *Config) SetHeaders(req *http.Request, setAuthHeader bool)

SetHeaders sets the configured ac headers to req.

type ConfigOptions

type ConfigOptions func(config *HTTPClientConfig)

ConfigOptions options which helps build Config

func WithBasicAuth

func WithBasicAuth(username, password string) ConfigOptions

WithBasicAuth returns AuthConfigOptions and initialized BasicAuthConfig based on given params

func WithBearer

func WithBearer(token string) ConfigOptions

WithBearer returns AuthConfigOptions and set BearerToken or BearerTokenFile based on given params

func WithHeaders

func WithHeaders(headers string) ConfigOptions

WithHeaders returns AuthConfigOptions and set Headers based on the given params

type HTTPClientConfig

type HTTPClientConfig struct {
	BasicAuth   *BasicAuthConfig
	BearerToken string
	Headers     string
}

HTTPClientConfig represents http client config.

func (*HTTPClientConfig) NewConfig

func (hcc *HTTPClientConfig) NewConfig() (*Config, error)

NewConfig creates auth config for the given hcc.

type Options

type Options struct {
	// BasicAuth contains optional BasicAuthConfig.
	BasicAuth *BasicAuthConfig

	// BearerToken contains optional bearer token.
	BearerToken string

	// Headers contains optional http request headers in the form 'Foo: bar'.
	Headers string
}

Options contain options, which must be passed to NewConfig.

func (*Options) NewConfig

func (opts *Options) NewConfig() (*Config, error)

NewConfig creates auth config from the given opts.

Jump to

Keyboard shortcuts

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