Webhook User Guide

Learn how to use and configure the webhook functionality of your application.

Overview

The webhook functionality is designed to:

API Endpoints

1. Generate API Key

Endpoint: /generate-api-key

Method: POST

Description: Generates a new API key for authentication purposes.

Response:


201 (Success):
{
  "status": "success",
  "name": "Generated API Key Name",
  "token": "Generated API Key Token"
}
500 (Error):
{
  "status": "error",
  "message": "Error details"
}
      

2. Generate Webhook Secret

Endpoint: /generate-webhook-secret

Method: POST

Description: Generates a new secret key for webhook validation.

Response:


201 (Success):
{
  "status": "success",
  "webhook_secret": "Generated Webhook Secret"
}
500 (Error):
{
  "status": "error",
  "message": "Error details"
}
      

3. Handle Webhook

Endpoint: /webhook

Method: POST

Description: Processes incoming webhook events from GitHub.

Features:

Expected Headers:

Response:


200 (Ignored Event):
{
  "status": "ignored",
  "event": "event_type"
}
403 (Invalid Signature):
{
  "error": "Invalid GitHub signature"
}
500 (Processing Error):
{
  "error": "Failed to process payload: Error details"
}
      

CLI Commands

1. Regenerate Webhook Secret

Command: regenerate-webhook-secret

Description: Regenerates the webhook secret key for validating incoming requests.

Output:


New webhook secret generated: <Generated Secret>
      

Webhook Signature Verification

Function: verify_signature(payload, signature, secret)

Purpose: Validates the HMAC signature of the payload using the stored webhook secret.

Process:

Returns:

Repository Processing

Steps:

Clone the Repository:

Execute Dobbuild.yaml:

Generate Results Path:

Function Highlights:

Webhook Processing Flow

Receive Webhook:

Validate Signature:

Parse Payload:

Check for Changes in Dobbuild.yaml:

Clone and Process Repository:

Return Response:

Error Handling

Invalid Signature:

Returns a 403 Forbidden response with an error message.

File Not Found:

Aborts if the required Dobbuild.yaml file is missing.

Execution Errors:

Logs and returns details of subprocess or unexpected errors.

By following this guide, users can efficiently utilize the webhook functionality for automated processing of DevOps workflows.