mirror of
https://github.com/rickbarrette/redmine_qbo.git
synced 2026-04-02 16:21:58 -04:00
Refactor: Enhance QboWebhookProcessor with logging for signature validation
This commit is contained in:
@@ -21,9 +21,12 @@ class QboWebhookProcessor
|
|||||||
WebhookProcessJob.perform_later(body)
|
WebhookProcessJob.perform_later(body)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
# Validates the QuickBooks webhook request by computing the HMAC signature and comparing it to the provided signature. Returns false if either the signature or secret is blank, or if the computed signature does not match the provided signature.
|
# Validates the QuickBooks webhook request by computing the HMAC signature and comparing it to the provided signature. Returns false if either the signature or secret is blank, or if the computed signature does not match the provided signature.
|
||||||
def self.valid_signature?(body, signature, secret)
|
def self.valid_signature?(body, signature, secret)
|
||||||
return false if signature.blank? || secret.blank?
|
return false if signature.blank? || secret.blank?
|
||||||
|
log "Validating signature"
|
||||||
|
|
||||||
digest = OpenSSL::Digest.new('sha256')
|
digest = OpenSSL::Digest.new('sha256')
|
||||||
computed = Base64.strict_encode64(
|
computed = Base64.strict_encode64(
|
||||||
@@ -32,4 +35,8 @@ class QboWebhookProcessor
|
|||||||
|
|
||||||
ActiveSupport::SecurityUtils.secure_compare(computed, signature)
|
ActiveSupport::SecurityUtils.secure_compare(computed, signature)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.log(msg)
|
||||||
|
Rails.logger.info "[QboWebhookProcessor] #{msg}"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
Reference in New Issue
Block a user