webhook

package
v0.5.2 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	InvalidWebhookAuthenticationConfig = "invalid webhook authentication configuration"
	SignatureHeaderButNoSecretError    = "secret not configured for validating webhook signature"
	NoSignatureHeaderButSecretError    = "missing webhook signature"
	MultipleSignatureHeadersError      = "multiple signature headers found"
	InvalidSignatureError              = "invalid signature in request"
)

Variables

View Source
var (
	ErrUnmarshalEvent           = errors.New("error unmarshaling event")
	ErrUnsupportedWebhookEvent  = errors.New("unsupported webhook event")
	ErrUnsupportedContentType   = errors.New("unsupported content type for webhook request")
	ErrFailedToParseContentType = errors.New("failed to parse content type")
	ErrFailsToParseBody         = errors.New("failed to parse body")
)
View Source
var (
	ErrMissingFieldID = fmt.Errorf("missing id field in event")
)
View Source
var (
	ErrWebhookPathRequired = errors.New("webhook path is required")
)

Functions

func GetEventTypeByPath added in v0.3.0

func GetEventTypeByPath(path string) func(data EventTypeParam) string

func GetHeaderValues added in v0.2.0

func GetHeaderValues(req ValidatingRequest, headerName, secret string) ([]string, error)

func GetPrimaryKeyByPath added in v0.2.0

func GetPrimaryKeyByPath(path string) func(parsedData gjson.Result) entities.PkFields

func SetupService

func SetupService(
	ctx context.Context,
	router *swagger.Router[fiber.Handler, fiber.Router],
	config *Configuration,
	p pipeline.IPipelineGroup,
) error

Types

type Authentication

type Authentication interface {
	CheckSignature(req ValidatingRequest) error
}

type Configuration

type Configuration struct {
	// Secret the webhook secret configuration for validating the data received
	Authentication Authentication `json:"authentication"`
	WebhookPath    string         `json:"webhookPath"`

	Events *Events `json:"events,omitempty"`
}

Configuration is the representation of the configuration for a Jira Cloud webhook

func (*Configuration) CheckSignature added in v0.2.0

func (c *Configuration) CheckSignature(req ValidatingRequest) error

func (*Configuration) Validate

func (c *Configuration) Validate() error

type ContentTypeConfig added in v0.3.0

type ContentTypeConfig map[string]string

ContentTypeConfig allows configuring how to extract the payload field for a given content-type

type Event

type Event struct {
	Operation  entities.Operation
	GetFieldID func(parsedData gjson.Result) entities.PkFields
}

type EventTypeParam added in v0.3.0

type EventTypeParam struct {
	Data    gjson.Result
	Headers http.Header
}

type Events

type Events struct {
	Supported    map[string]Event
	GetEventType func(data EventTypeParam) string
	PayloadKey   ContentTypeConfig
}

type HMAC added in v0.2.0

type HMAC struct {
	Secret     config.SecretSource `json:"secret"`
	HeaderName string              `json:"headerName"`
}

func (HMAC) CheckSignature added in v0.2.0

func (h HMAC) CheckSignature(req ValidatingRequest) error

CheckSignature will read the webhook signature header and the given secret for validating the webhook payload. It will fail if there is a mismatch in the signatures and if a signature or a secret is provided and the other is not present.

type RequestInfo added in v0.3.0

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

type ValidatingRequest

type ValidatingRequest interface {
	GetReqHeaders() map[string][]string
	Body() []byte
}

Jump to

Keyboard shortcuts

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