feat(hook): add AllowInsecure option for TLS verification
Some checks failed
CI / Test (1.23) (push) Failing after -20m40s
CI / Test (1.22) (push) Failing after -20m33s
CI / Build (push) Failing after -23m2s
CI / Lint (push) Failing after -22m34s

* Introduced AllowInsecure field in Hook configuration to skip TLS certificate verification.
* Updated database schema and models to support the new field.
* Modified HTTP client behavior based on AllowInsecure setting.
This commit is contained in:
Hein
2026-02-20 15:33:53 +02:00
parent 35a548e7e2
commit 3fb65e0285
8 changed files with 37 additions and 16 deletions

View File

@@ -3,6 +3,7 @@ package hooks
import (
"bytes"
"context"
"crypto/tls"
"encoding/json"
"fmt"
"io"
@@ -335,6 +336,18 @@ func (m *Manager) sendToHook(ctx context.Context, hook config.Hook, payload inte
eventCtx = context.Background()
}
// Select the appropriate HTTP client. If the hook allows insecure TLS, use a
// dedicated client that skips certificate verification; otherwise use the shared client.
httpClient := m.client
if hook.AllowInsecure {
httpClient = &http.Client{
Timeout: 30 * time.Second,
Transport: &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: true}, //nolint:gosec // intentional: user opted in via AllowInsecure
},
}
}
// Publish hook triggered event
m.eventBus.Publish(events.HookTriggeredEvent(eventCtx, hook.ID, hook.Name, hook.URL, payload))
@@ -391,7 +404,7 @@ func (m *Manager) sendToHook(ctx context.Context, hook config.Hook, payload inte
logging.Debug("Sending to hook", "hook_id", hook.ID, "url", hook.URL)
resp, err := m.client.Do(req)
resp, err := httpClient.Do(req)
if err != nil {
logging.Error("Failed to send to hook", "hook_id", hook.ID, "error", err)
m.eventBus.Publish(events.HookFailedEvent(eventCtx, hook.ID, hook.Name, err))