authentication

package
v2.15.1 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AuthModesKey = "authModes"
)

Variables

This section is empty.

Functions

func CreateHTTPRoundTripper added in v2.6.0

func CreateHTTPRoundTripper(roundTripperType TransportType, auth *AuthMeta, conf ...*HTTPTransport) (rt http.RoundTripper, err error)

func GetBearerToken added in v2.9.0

func GetBearerToken(auth *AuthMeta) string

func NewTLSConfig added in v2.9.0

func NewTLSConfig(auth *AuthMeta, unsafeSsl bool) (*tls.Config, error)

func ParseEndpointParams added in v2.13.0

func ParseEndpointParams(inputStr string) (url.Values, error)

ParseEndpointParams parse OAuth endpoint params from URL-encoded query string.

func ParseScope added in v2.12.0

func ParseScope(inputStr string) []string

ParseScope parse OAuth scopes from a comma separated string whitespace is trimmed

Types

type AuthMeta added in v2.6.0

type AuthMeta struct {
	// bearer auth
	EnableBearerAuth bool
	BearerToken      string

	// basic auth
	EnableBasicAuth bool
	Username        string
	Password        string // +optional

	// client certification
	EnableTLS bool
	Cert      string
	Key       string
	CA        string

	// oAuth2
	EnableOAuth    bool
	OauthTokenURI  string
	Scopes         []string
	ClientID       string
	ClientSecret   string
	EndpointParams url.Values

	// custom auth header
	EnableCustomAuth bool
	CustomAuthHeader string
	CustomAuthValue  string
}

AuthMeta is the metadata for the authentication types Deprecated: use Config instead

func GetAuthConfigs added in v2.6.0

func GetAuthConfigs(triggerMetadata, authParams map[string]string) (out *AuthMeta, err error)

type BasicAuth added in v2.15.0

type BasicAuth struct {
	Username string `keda:"name=username, order=authParams"`
	Password string `keda:"name=password, order=authParams"`
}

BasicAuth is a basic authentication type

type CertAuth added in v2.15.0

type CertAuth struct {
	Cert string `keda:"name=cert, order=authParams"`
	Key  string `keda:"name=key, order=authParams"`
	CA   string `keda:"name=ca, order=authParams"`
}

CertAuth is a client certificate authentication type

type Config added in v2.15.0

type Config struct {
	Modes []Type `` /* 130-byte string literal not displayed */

	BearerToken string `keda:"name=bearerToken, order=authParams, optional"`
	BasicAuth   `keda:"optional"`
	CertAuth    `keda:"optional"`
	OAuth       `keda:"optional"`
	CustomAuth  `keda:"optional"`
}

Config is the configuration for the authentication types

func (*Config) Disabled added in v2.15.0

func (c *Config) Disabled() bool

Disabled returns true if no auth modes are enabled

func (*Config) Enabled added in v2.15.0

func (c *Config) Enabled(mode Type) bool

Enabled returns true if given auth mode is enabled

func (*Config) EnabledBasicAuth added in v2.15.0

func (c *Config) EnabledBasicAuth() bool

func (*Config) EnabledBearerAuth added in v2.15.0

func (c *Config) EnabledBearerAuth() bool

func (*Config) EnabledCustomAuth added in v2.15.0

func (c *Config) EnabledCustomAuth() bool

func (*Config) EnabledOAuth added in v2.15.0

func (c *Config) EnabledOAuth() bool

func (*Config) EnabledTLS added in v2.15.0

func (c *Config) EnabledTLS() bool

helpers for checking enabled auth modes

func (*Config) GetBearerToken added in v2.15.0

func (c *Config) GetBearerToken() string

GetBearerToken returns the bearer token with the Bearer prefix

func (*Config) ToAuthMeta added in v2.15.0

func (c *Config) ToAuthMeta() *AuthMeta

ToAuthMeta converts the Config to deprecated AuthMeta

func (*Config) Validate added in v2.15.0

func (c *Config) Validate() error

Validate validates the Config and returns an error if it is invalid

type CustomAuth added in v2.15.0

type CustomAuth struct {
	CustomAuthHeader string `keda:"name=customAuthHeader, order=authParams"`
	CustomAuthValue  string `keda:"name=customAuthValue,  order=authParams"`
}

CustomAuth is a custom header authentication type

type HTTPTransport added in v2.6.0

type HTTPTransport struct {
	MaxIdleConnDuration time.Duration
	ReadTimeout         time.Duration
	WriteTimeout        time.Duration
}

type OAuth added in v2.15.0

type OAuth struct {
	OauthTokenURI  string     `keda:"name=oauthTokenURI,  order=authParams"`
	Scopes         []string   `keda:"name=scopes,         order=authParams"`
	ClientID       string     `keda:"name=clientID,       order=authParams"`
	ClientSecret   string     `keda:"name=clientSecret,   order=authParams"`
	EndpointParams url.Values `keda:"name=endpointParams, order=authParams"`
}

OAuth is an oAuth2 authentication type

type TransportType added in v2.6.0

type TransportType int

TransportType is type of http transport

const (
	NetHTTP  TransportType = iota // NetHTTP standard Go net/http client.
	FastHTTP                      // FastHTTP Fast http client.
)

type Type

type Type string

Type describes the authentication type used in a scaler

const (
	// APIKeyAuthType is an auth type using an API key
	APIKeyAuthType Type = "apiKey"
	// BasicAuthType is an auth type using basic auth
	BasicAuthType Type = "basic"
	// TLSAuthType is an auth type using TLS
	TLSAuthType Type = "tls"
	// BearerAuthType is an auth type using a bearer token
	BearerAuthType Type = "bearer"
	// CustomAuthType is an auth type using a custom header
	CustomAuthType Type = "custom"
	// OAuthType is an auth type using a oAuth2
	OAuthType Type = "oauth"
)

Jump to

Keyboard shortcuts

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