Skip to content

firehydrant/firehydrant-webhook-handler-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FireHydrant Webhook Handler

A Go application for handling webhooks from FireHydrant.com. This project demonstrates how to receive, verify, and process webhooks from FireHydrant's incident management platform.

Features

  • HTTP server using Gorilla Mux for routing
  • HMAC signature verification for webhook security
  • Configurable using command-line flags, environment variables, or config file
  • JSON parsing of FireHydrant incident data
  • Graceful shutdown handling

Installation

Building from source

git clone https://github.com/bobbytables/firehydrant-webhook-handler-example.git
cd firehydrant-webhook-handler-example
go build -o firehydrant-webhook cmd/firehydrant/main.go

Usage

The application supports multiple commands:

  • server: Start the webhook server
  • version: Display version information

Running the server

# Run with default settings
./firehydrant-webhook server

# Specify port and HMAC secret
./firehydrant-webhook server -p 9000 -s your-webhook-secret

# Enable debug mode
./firehydrant-webhook server -d

# Use a specific config file
./firehydrant-webhook server -c /path/to/config.yaml

Displaying version information

./firehydrant-webhook version

Configuration

Configuration can be provided through:

  1. Command-line flags
  2. Environment variables
  3. Config file (YAML)

Command-line Flags

  • -p, --port: HTTP server port (default: 8080)
  • -s, --secret: HMAC secret for webhook verification
  • -d, --debug: Enable debug mode for verbose logging
  • -c, --config: Path to config file

Environment Variables

Environment variables use the prefix FH_ and convert dots to underscores:

  • FH_SERVER_PORT: HTTP server port
  • FH_WEBHOOK_SECRET: HMAC secret for webhook verification
  • FH_WEBHOOK_DEBUG: Enable debug mode (true/false)

Config File

The default config file is config.yaml in the current directory. You can specify a different file with the -c flag.

Example config.yaml:

server:
  port: 8080

webhook:
  # Secret used for HMAC verification
  secret: your-webhook-secret

  # Enable debug mode
  debug: false

Setting Up FireHydrant Webhooks

  1. In FireHydrant, go to Settings > Integrations > Webhooks
  2. Add a new webhook with your server's URL (e.g., https://your-server.com/webhook)
  3. Set the webhook secret and use the same value in your webhook handler configuration
  4. Select the incident events you want to receive
  5. Save the webhook configuration

Webhook Verification

The application uses HMAC-SHA256 to verify webhook requests from FireHydrant. When a webhook is sent, FireHydrant includes a signature in the fh-signature header. The application computes its own signature using the shared secret and compares it with the provided signature.

To generate a secure random secret, you can use:

openssl rand -hex 32

Customizing Webhook Handling

To customize how webhooks are processed, modify the processWebhook method in internal/handler/webhook.go. This method receives the parsed webhook payload and can be extended to:

  • Update data lakes
  • Update an internal database
  • Send notifications
  • Trigger automated responses
  • Forward to other systems

License

MIT

About

Example repository for handling webhooks from FireHydrant in Go

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages