webhook

package
v0.3.0-rc.0 Latest Latest
Warning

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

Go to latest
Published: May 29, 2025 License: Apache-2.0 Imports: 18 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")
)
View Source
var (
	ErrMissingFieldID = fmt.Errorf("missing id field in event")
)
View Source
var (
	ErrWebhookPathRequired = errors.New("webhook path is required")
)

Functions

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.Group,
) 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 Event

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

type Events

type Events struct {
	Supported          map[string]Event
	EventTypeFieldPath string
}

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