webhook

package module
v0.0.0-...-4ed8630 Latest Latest
Warning

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

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

README

Rockset receiver webhook

A webhook receiver that runs as an AWS lambda and writes the payloads it receives to Rockset collections.

Configuration

The webhook receiver is configured using environment variables. The following variables are required:

  • ROCKSET_APIKEY - the Rockset API key to use.
  • ROCKSET_APISERVER - the Rockset API server to use.
  • WORKSPACE - the default Rockset workspace where collections are located.
  • PATHS - a JSON object that maps webhook paths to Rockset collections.

The format of the PATHS variable that maps the webhook path to a Rockset collection:

{
  "/github": {
    "collection": "github",
    "workspace": "webhooks"
  },
  "/pagerduty": {
    "collection": "pagerduty",
    "workspace": "webhooks"
  }
}

Docker Image

The docker image is published at docker.io/rockset/webhook, and in the future we might publish a vanity URL using this method.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	BadDocumentErr = fmt.Errorf("failed to add document")
	MissingPathErr = fmt.Errorf("missing path configuration")
)
View Source
var AuthFailedErr = errors.New("authentication failed")

Functions

func LoadConfig

func LoadConfig(ctx context.Context, path string) (string, error)

Types

type AuthConfig

type AuthConfig struct {
	// Type is the type of authentication to use, one of "header" or "signature"
	Type   string `json:"type"`
	Secret string `json:"secret"`
	Header string `json:"header"`
}

type Authenticator

type Authenticator interface {
	Authenticate(req events.LambdaFunctionURLRequest) error
}

type Config

type Config struct {
	Workspace          string     `json:"workspace"`
	Collection         string     `json:"collection"`
	WrapPayloadInArray bool       `json:"wrap"`
	Auth               AuthConfig `json:"auth"`
}

type Configs

type Configs map[string]Config

type FailAuthenticator

type FailAuthenticator struct{}

func (*FailAuthenticator) Authenticate

type Handler

type Handler struct {
	// Rockset *rockset.RockClient
	Rockset Rockset
	// Workspace is the default workspace to use if not specified in the path
	Workspace string
	// Configs is a map of endpoint configurations
	Configs Configs
	// Debug is a flag to enable debug logging
	Debug bool
}

func New

func New(env func(string) (string, bool)) (*Handler, error)

func (Handler) AuthenticatorForRequest

func (h Handler) AuthenticatorForRequest(path string) Authenticator

func (Handler) HandlePayload

func (h Handler) HandlePayload(ctx context.Context, request events.LambdaFunctionURLRequest) error

type HeaderAuthenticator

type HeaderAuthenticator struct {
	Header string
	Secret string
}

func (*HeaderAuthenticator) Authenticate

type NoopAuthenticator

type NoopAuthenticator struct{}

func (*NoopAuthenticator) Authenticate

type Rockset

type Rockset interface {
	AddDocumentsRaw(ctx context.Context, workspace, collection string, body json.RawMessage) ([]openapi.DocumentStatus, error)
}

type SignatureAuthenticator

type SignatureAuthenticator struct {
	SigningSecret string
	// Header is the name of the header that contains the signature, defaults to "X-Signature" if left empty.
	Header string
}

SignatureAuthenticator implements SHA256 HMAC signature verification

func (*SignatureAuthenticator) Authenticate

Directories

Path Synopsis
cmd
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

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