promauth

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2024 License: AGPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Authorization

type Authorization struct {
	Type            string  `yaml:"type,omitempty" toml:"type"`
	Credentials     *Secret `yaml:"credentials,omitempty" toml:"credentials"`
	CredentialsFile string  `yaml:"credentials_file,omitempty" toml:"credentials_file"`
}

Authorization represents generic authorization config.

See https://prometheus.io/docs/prometheus/latest/configuration/configuration/

type BasicAuthConfig

type BasicAuthConfig struct {
	Username     string  `yaml:"username" toml:"username"`
	Password     *Secret `yaml:"password,omitempty" toml:"password"`
	PasswordFile string  `yaml:"password_file,omitempty" toml:"password_file"`
}

BasicAuthConfig represents basic auth config.

func (*BasicAuthConfig) NewConfig

func (ba *BasicAuthConfig) NewConfig(baseDir string) (*Config, error)

NewConfig creates auth config for the given ba.

type Config

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

Config is auth config.

func (*Config) GetAuthHeader

func (ac *Config) GetAuthHeader() (string, error)

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

func (*Config) HeadersNoAuthString

func (ac *Config) HeadersNoAuthString() string

HeadersNoAuthString returns string representation of ac headers

func (*Config) NewTLSConfig

func (ac *Config) NewTLSConfig() (*tls.Config, error)

NewTLSConfig returns new TLS config for the given ac.

func (*Config) SetFasthttpHeaders

func (ac *Config) SetFasthttpHeaders(req *fasthttp.Request, setAuthHeader bool) error

SetFasthttpHeaders sets the configured ac headers to req.

func (*Config) SetHeaders

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

SetHeaders sets the configured ac headers to req.

func (*Config) String

func (ac *Config) String() string

String returns human-readable representation for ac.

It is also used for comparing Config objects for equality. If two Config objects have the same string representation, then they are considered equal.

type HTTPClientConfig

type HTTPClientConfig struct {
	Authorization   *Authorization   `yaml:"authorization,omitempty" toml:"authorization"`
	BasicAuth       *BasicAuthConfig `yaml:"basic_auth,omitempty" toml:"basic_auth"`
	BearerToken     *Secret          `yaml:"bearer_token,omitempty" toml:"bearer_token"`
	BearerTokenFile string           `yaml:"bearer_token_file,omitempty" toml:"bearer_token_file"`
	OAuth2          *OAuth2Config    `yaml:"oauth2,omitempty" toml:"oauth2"`
	TLSConfig       *TLSConfig       `yaml:"tls_config,omitempty" toml:"tls_config"`

	// Headers contains optional HTTP headers, which must be sent in the request to the server
	Headers []string `yaml:"headers,omitempty" toml:"headers"`

	// FollowRedirects specifies whether the client should follow HTTP 3xx redirects.
	FollowRedirects *bool `yaml:"follow_redirects,omitempty" toml:"follow_redirects"`
}

HTTPClientConfig represents http client config.

func (*HTTPClientConfig) NewConfig

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

NewConfig creates auth config for the given hcc.

type OAuth2Config

type OAuth2Config struct {
	ClientID         string            `yaml:"client_id" toml:"client_id"`
	ClientSecret     *Secret           `yaml:"client_secret,omitempty" toml:"client_secret"`
	ClientSecretFile string            `yaml:"client_secret_file,omitempty" toml:"client_secret_file"`
	Scopes           []string          `yaml:"scopes,omitempty" toml:"scopes"`
	TokenURL         string            `yaml:"token_url" toml:"token_url"`
	EndpointParams   map[string]string `yaml:"endpoint_params,omitempty" toml:"endpoint_params"`
	TLSConfig        *TLSConfig        `yaml:"tls_config,omitempty" toml:"tls_config"`
	ProxyURL         string            `yaml:"proxy_url,omitempty" toml:"proxy_url"`
}

OAuth2Config represent OAuth2 configuration

type Options

type Options struct {
	// BaseDir is an optional path to a base directory for resolving
	// relative filepaths in various config options.
	//
	// It is set to the current directory by default.
	BaseDir string

	// Authorization contains optional Authorization.
	Authorization *Authorization

	// BasicAuth contains optional BasicAuthConfig.
	BasicAuth *BasicAuthConfig

	// BearerToken contains optional bearer token.
	BearerToken string

	// BearerTokenFile contains optional path to a file with bearer token.
	BearerTokenFile string

	// OAuth2 contains optional OAuth2Config.
	OAuth2 *OAuth2Config

	// TLSconfig contains optional TLSConfig.
	TLSConfig *TLSConfig

	// 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.

type ProxyClientConfig

type ProxyClientConfig struct {
	Authorization   *Authorization   `yaml:"proxy_authorization,omitempty" toml:"proxy_authorization"`
	BasicAuth       *BasicAuthConfig `yaml:"proxy_basic_auth,omitempty" toml:"proxy_basic_auth"`
	BearerToken     *Secret          `yaml:"proxy_bearer_token,omitempty" toml:"proxy_bearer_token"`
	BearerTokenFile string           `yaml:"proxy_bearer_token_file,omitempty" toml:"proxy_bearer_token_file"`
	OAuth2          *OAuth2Config    `yaml:"proxy_oauth2,omitempty" toml:"proxy_oauth2"`
	TLSConfig       *TLSConfig       `yaml:"proxy_tls_config,omitempty" toml:"proxy_tls_config"`

	// Headers contains optional HTTP headers, which must be sent in the request to the proxy
	Headers []string `yaml:"proxy_headers,omitempty" toml:"proxy_headers"`
}

ProxyClientConfig represents proxy client config.

func (*ProxyClientConfig) NewConfig

func (pcc *ProxyClientConfig) NewConfig(baseDir string) (*Config, error)

NewConfig creates auth config for the given pcc.

type Secret

type Secret struct {
	S string
}

Secret represents a string secret such as password or auth token.

It is marshaled to "<secret>" string in yaml.

This is needed for hiding secret strings in /config page output. See https://github.com/VictoriaMetrics/VictoriaMetrics/issues/1764

func NewSecret

func NewSecret(s string) *Secret

NewSecret returns new secret for s.

func (*Secret) MarshalYAML

func (s *Secret) MarshalYAML() (interface{}, error)

MarshalYAML implements yaml.Marshaler interface.

It substitutes the secret with "<secret>" string.

func (*Secret) String

func (s *Secret) String() string

String returns the secret in plaintext.

func (*Secret) UnmarshalTOML added in v0.2.0

func (s *Secret) UnmarshalTOML(b []byte) error

func (*Secret) UnmarshalText added in v0.2.0

func (s *Secret) UnmarshalText(b []byte) error

func (*Secret) UnmarshalYAML

func (s *Secret) UnmarshalYAML(f func(interface{}) error) error

UnmarshalYAML implements yaml.Unmarshaler interface.

type TLSConfig

type TLSConfig struct {
	CA                 string `yaml:"ca,omitempty" toml:"ca"`
	CAFile             string `yaml:"ca_file,omitempty" toml:"ca_file"`
	Cert               string `yaml:"cert,omitempty" toml:"cert"`
	CertFile           string `yaml:"cert_file,omitempty" toml:"cert_file"`
	Key                string `yaml:"key,omitempty" toml:"key"`
	KeyFile            string `yaml:"key_file,omitempty" toml:"key_file"`
	ServerName         string `yaml:"server_name,omitempty" toml:"server_name"`
	InsecureSkipVerify bool   `yaml:"insecure_skip_verify,omitempty" toml:"insecure_skip_verify"`
	MinVersion         string `yaml:"min_version,omitempty" toml:"min_version"`
}

TLSConfig represents TLS config.

See https://prometheus.io/docs/prometheus/latest/configuration/configuration/#tls_config

Jump to

Keyboard shortcuts

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