Alerting: Add OAuth2 Support for Webhook Receiver (#106302)
* Add to available channels * Export * Fix bug in deeply nested secrets BE: Slice re-use bug when traversing deeply. FE: Only at most one level of nesting was being taken into account when determining secureFields keys. This change adds a new field on NotificationChannelOption: secureFieldKey. This is populated on API GET via transform. This change gives us the option to hardcode secureFieldKey in the backend and no longer calculate the key via settings topology. * Update grafana/alerting to 3e20fda3b872 * Prettier * Linting * Fix IntegrationConfig test to catch secure field mismatch
This commit is contained in:
@@ -324,6 +324,7 @@ type WebhookIntegration struct {
|
||||
Message *string `json:"message,omitempty" yaml:"message,omitempty" hcl:"message"`
|
||||
TLSConfig *TLSConfig `json:"tlsConfig,omitempty" yaml:"tlsConfig,omitempty" hcl:"tlsConfig,block"`
|
||||
HMACConfig *HMACConfig `json:"hmacConfig,omitempty" yaml:"hmacConfig,omitempty" hcl:"hmacConfig,block"`
|
||||
HTTPConfig *HTTPClientConfig `json:"http_config,omitempty" yaml:"http_config,omitempty" hcl:"http_config,block"`
|
||||
|
||||
Payload *CustomPayload `json:"payload,omitempty" yaml:"payload,omitempty" hcl:"payload,block"`
|
||||
}
|
||||
@@ -343,6 +344,41 @@ type HMACConfig struct {
|
||||
TimestampHeader string `yaml:"timestampHeader,omitempty" json:"timestampHeader,omitempty" hcl:"timestamp_header"`
|
||||
}
|
||||
|
||||
// HTTPClientConfig holds common configurations for notifier HTTP clients.
|
||||
type HTTPClientConfig struct {
|
||||
OAuth2Config *OAuth2Config `json:"oauth2,omitempty" yaml:"oauth2,omitempty" hcl:"oauth2,block"`
|
||||
}
|
||||
|
||||
type ProxyConfig struct {
|
||||
// ProxyURL is the HTTP proxy server to use to connect to the targets.
|
||||
ProxyURL *string `yaml:"proxy_url,omitempty" json:"proxy_url,omitempty" hcl:"proxy_url"`
|
||||
// NoProxy contains addresses that should not use a proxy.
|
||||
NoProxy *string `yaml:"no_proxy,omitempty" json:"no_proxy,omitempty" hcl:"no_proxy"`
|
||||
// ProxyFromEnvironment uses environment HTTP_PROXY, HTTPS_PROXY and NO_PROXY to determine proxies.
|
||||
ProxyFromEnvironment *bool `yaml:"proxy_from_environment,omitempty" json:"proxy_from_environment,omitempty" hcl:"proxy_from_environment"`
|
||||
// ProxyConnectHeader optionally specifies headers to send to proxies during CONNECT requests.
|
||||
ProxyConnectHeader *map[string]string `yaml:"proxy_connect_header,omitempty" json:"proxy_connect_header,omitempty" hcl:"proxy_connect_header"`
|
||||
}
|
||||
|
||||
type OAuth2Config struct {
|
||||
// ClientID is the OAuth2 client ID.
|
||||
ClientID string `json:"client_id" yaml:"client_id" hcl:"client_id"`
|
||||
// ClientSecret is the OAuth2 client secret.
|
||||
ClientSecret *Secret `json:"client_secret" yaml:"client_secret" hcl:"client_secret"`
|
||||
// TokenURL is the URL to get the OAuth2 token.
|
||||
TokenURL string `json:"token_url" yaml:"token_url" hcl:"token_url"`
|
||||
|
||||
// Scopes is the optional list of OAuth2 scopes.
|
||||
Scopes *[]string `json:"scopes,omitempty" yaml:"scopes,omitempty" hcl:"scopes"`
|
||||
// EndpointParams is the optional map of additional parameters to include in the token request.
|
||||
EndpointParams *map[string]string `json:"endpoint_params,omitempty" yaml:"endpoint_params,omitempty" hcl:"endpoint_params"`
|
||||
// TLSConfig is the optional TLS configuration to use for the OAuth2 token request.
|
||||
TLSConfig *TLSConfig `json:"tls_config,omitempty" yaml:"tls_config,omitempty" hcl:"tls_config,block"`
|
||||
|
||||
// ProxyConfig is the optional proxy configuration to use for the OAuth2 token request.
|
||||
ProxyConfig *ProxyConfig `json:"proxy_config,omitempty" yaml:"proxy_config,omitempty" hcl:"proxy_config,block"`
|
||||
}
|
||||
|
||||
type WecomIntegration struct {
|
||||
DisableResolveMessage *bool `json:"-" yaml:"-" hcl:"disable_resolve_message"`
|
||||
|
||||
|
||||
Reference in New Issue
Block a user