webhook

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2025 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

Package webhook implements the webhook auth mode

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrMethodNotAllowed occurs when the method is neither GET nor POST.
	ErrMethodNotAllowed = errors.New("webhook mode must be one of GET or POST")

	// ErrResponseBodyRequired occurs when the response body have no content.
	ErrResponseBodyRequired = errors.New("response body must have content")

	// ErrMalformedTransformedResponseBody occurs when the transformed response body is malformed.
	ErrMalformedTransformedResponseBody = errors.New("malformed response body. Expected a map")
)

Functions

This section is empty.

Types

type CustomWebhookAuthHeadersConfig

type CustomWebhookAuthHeadersConfig struct {
	// The headers to be forwarded from the client request.
	Forward *goutils.AllOrListString
	// The additional headers to be sent to the auth hook.
	Additional map[string]jmes.FieldMappingEntryString
}

CustomWebhookAuthHeadersConfig represents a custom webhook auth header config.

func NewCustomWebhookAuthHeadersConfig

func NewCustomWebhookAuthHeadersConfig(
	input *WebhookAuthHeadersConfig,
	getEnvFunc goenvconf.GetEnvFunc,
) (*CustomWebhookAuthHeadersConfig, error)

func (CustomWebhookAuthHeadersConfig) Equal

Equal checks if the target value is equal.

type CustomWebhookRequestConfig

type CustomWebhookRequestConfig struct {
	Headers *CustomWebhookAuthHeadersConfig
	Body    gotransform.TemplateTransformer
}

CustomWebhookRequestConfig represents a custom webhook request config.

func (CustomWebhookRequestConfig) Equal

Equal checks if the target value is equal.

type CustomWebhookResponseConfig

type CustomWebhookResponseConfig struct {
	Body gotransform.TemplateTransformer
}

CustomWebhookResponseConfig represents a custom webhook response config.

func (CustomWebhookResponseConfig) Equal

Equal checks if the target value is equal.

type RelyAuthWebhookConfig

type RelyAuthWebhookConfig struct {
	// Unique identity of the auth config.
	// If not set, ID will be the index of the array.
	ID string `json:"id,omitempty" yaml:"id,omitempty"`
	// Authentication mode which is always webhook.
	Mode authmode.AuthMode `json:"mode" yaml:"mode"`
	// Request method. Accept GET or POST.
	Method string `json:"method" yaml:"method"`
	// The URL of the authentication webhook.
	URL goenvconf.EnvString `json:"url" yaml:"url"`
	// Brief description of the auth config.
	Description string `json:"description,omitempty" yaml:"description,omitempty"`
	// Configurations for request headers and transformed request body to be sent to the auth hook.
	CustomRequest *WebhookAuthCustomRequestConfig `json:"customRequest,omitempty" yaml:"customRequest,omitempty"`
	// The configuration for transforming response bodies.
	CustomResponse *WebhookAuthCustomResponseConfig `json:"customResponse,omitempty" yaml:"customResponse,omitempty"`
	// Configurations for the HTTP client.
	HTTPClient *httpconfig.HTTPClientConfig `json:"httpClient,omitempty" yaml:"httpClient,omitempty"`
}

RelyAuthWebhookConfig contains the configuration schema for webhook authentication.

func NewRelyAuthWebhookConfig

func NewRelyAuthWebhookConfig(
	webhookURL goenvconf.EnvString,
	method string,
) *RelyAuthWebhookConfig

NewRelyAuthWebhookConfig creates a new RelyAuthWebhookConfig instance.

func (RelyAuthWebhookConfig) Equal

Equal checks if the target value is equal.

func (RelyAuthWebhookConfig) GetMode

GetMode get the auth mode of the current config.

func (RelyAuthWebhookConfig) IsZero

func (j RelyAuthWebhookConfig) IsZero() bool

IsZero if the current instance is empty.

func (RelyAuthWebhookConfig) JSONSchema

func (RelyAuthWebhookConfig) JSONSchema() *jsonschema.Schema

JSONSchema is used to generate a custom jsonschema.

func (RelyAuthWebhookConfig) Validate

func (j RelyAuthWebhookConfig) Validate() error

Validate if the current instance is valid.

type WebhookAuthCustomRequestConfig

type WebhookAuthCustomRequestConfig struct {
	// The configuration to transform request headers.
	Headers *WebhookAuthHeadersConfig `json:"headers,omitempty" yaml:"headers,omitempty"`
	// The configuration to transform request body.
	Body *gotransform.TemplateTransformerConfig `json:"body,omitempty"    yaml:"body,omitempty"`
}

WebhookAuthCustomRequestConfig represents the configuration for request headers and transformed request body to be sent to the auth hook.

func (WebhookAuthCustomRequestConfig) Equal

Equal checks if the target value is equal.

func (WebhookAuthCustomRequestConfig) IsZero

IsZero if the current instance is empty.

type WebhookAuthCustomResponseConfig

type WebhookAuthCustomResponseConfig struct {
	// The template to transform the response body.
	Body *gotransform.TemplateTransformerConfig `json:"response,omitempty" yaml:"response,omitempty"`
}

WebhookAuthCustomResponseConfig is the configuration for transforming response bodies.

func (WebhookAuthCustomResponseConfig) Equal

Equal checks if the target value is equal.

func (WebhookAuthCustomResponseConfig) IsZero

IsZero if the current instance is empty.

type WebhookAuthHeadersConfig

type WebhookAuthHeadersConfig struct {
	// The headers to be forwarded from the client request.
	Forward *goutils.AllOrListString `json:"forward,omitempty" yaml:"forward,omitempty"`
	// The additional headers to be sent to the auth hook.
	Additional map[string]jmes.FieldMappingEntryStringConfig `json:"additional,omitempty" yaml:"additional,omitempty"`
}

WebhookAuthHeadersConfig is the configuration for the headers to be sent to the auth hook.

func (WebhookAuthHeadersConfig) Equal

Equal checks if the target value is equal.

func (WebhookAuthHeadersConfig) IsZero

func (wa WebhookAuthHeadersConfig) IsZero() bool

IsZero if the current instance is empty.

type WebhookAuthenticator

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

WebhookAuthenticator implements the authenticator with API key.

func NewWebhookAuthenticator

func NewWebhookAuthenticator(
	ctx context.Context,
	config *RelyAuthWebhookConfig,
	opts authmode.RelyAuthenticatorOptions,
) (*WebhookAuthenticator, error)

NewWebhookAuthenticator creates a webhook authenticator instance.

func (*WebhookAuthenticator) Authenticate

Authenticate validates and authenticates the token from the auth webhook request.

func (*WebhookAuthenticator) Close

func (wa *WebhookAuthenticator) Close() error

Close handles the resources cleaning.

func (WebhookAuthenticator) Equal

Equal checks if the target value is equal.

func (*WebhookAuthenticator) Mode

Mode returns the auth mode of the current authenticator.

Jump to

Keyboard shortcuts

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