Sha256: 4fdd8effcd9824bd14955041613a7c783534bcd8711ebef143d7d0cb61ea9cb4

Contents?: true

Size: 662 Bytes

Versions: 4

Compression:

Stored size: 662 Bytes

Contents

module ChatworkWebhookVerify
  module ControllerExtension
    # @param token     [String] webhook token (default: `ChatworkWebhookVerify.config.token`)
    #
    # @raise [ActionController::BadRequest] signature is invalid
    def verify_chatwork_webhook_signature!(token = nil)
      ChatworkWebhookVerify.verify!(
        token:     token,
        body:      request.env["rack.input"].read,
        signature: request.headers["X-ChatWorkWebhookSignature"] || params[:chatwork_webhook_signature],
      )
    rescue ChatworkWebhookVerify::InvalidSignatureError, ::ArgumentError
      raise ActionController::BadRequest, "signature is invalid"
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
chatwork_webhook_verify-2.0.0 lib/chatwork_webhook_verify/controller_extension.rb
chatwork_webhook_verify-1.0.0 lib/chatwork_webhook_verify/controller_extension.rb
chatwork_webhook_verify-0.1.1 lib/chatwork_webhook_verify/controller_extension.rb
chatwork_webhook_verify-0.1.0 lib/chatwork_webhook_verify/controller_extension.rb