Class: Consyncful::WebhookController
- Inherits:
-
ActionController::API
- Object
- ActionController::API
- Consyncful::WebhookController
- Includes:
- ActionController::HttpAuthentication::Basic::ControllerMethods
- Defined in:
- app/controllers/consyncful/webhook_controller.rb
Overview
The Consyncful::WebhookController is responsible for handling incoming webhook requests that can trigger synchronization jobs within Consyncful.
Features:
-
Only responds to requests if
sync_modeis configured as:webhook. -
Optionally requires HTTP Basic authentication if
webhook_authentication_requiredis enabled in configuration. -
Exposes a single endpoint (
trigger_sync) that signals a sync process throughConsyncful::Sync.signal_webhook!.
Security:
-
Uses
ActionController::HttpAuthentication::Basicto enforce authentication when enabled. -
Compares provided credentials with configured values using
ActiveSupport::SecurityUtils.secure_compareto prevent timing attacks.
Responses:
-
Returns ‘404 Not Found` if webhooks are not enabled.
-
Returns ‘202 Accepted` after signaling a sync.
Instance Method Summary collapse
Instance Method Details
#trigger_sync ⇒ Object
27 28 29 30 31 32 |
# File 'app/controllers/consyncful/webhook_controller.rb', line 27 def trigger_sync return head :not_found unless use_webhooks? Consyncful::Sync.signal_webhook! head :accepted end |