Sha256: d9d3387241a50af982d26638f43718df52b3d02fb18bea5b468819d8543fa321

Contents?: true

Size: 875 Bytes

Versions: 3

Compression:

Stored size: 875 Bytes

Contents

module Immunio
  module CsrfHook
    extend ActiveSupport::Concern

    included do
      if method_defined? :verify_authenticity_token
        Immunio::Utils.alias_method_chain self, :verify_authenticity_token, :immunio
      end
    end

    protected
      def verify_authenticity_token_with_immunio
        Request.time "plugin", "#{Module.nesting[0]}::#{__method__}" do
          Immunio.logger.debug { "ActiveSupport checking CSRF token" }

          Immunio.run_hook! "csrf", "framework_csrf_check", valid: verified_request?

          Request.pause "plugin", "#{Module.nesting[0]}::#{__method__}" do
            verify_authenticity_token_without_immunio
          end
        end
      end
  end
end

Immunio::Plugin.load 'ActionController (CSRF)' do |plugin|
  ActionController::Base.send :include, Immunio::CsrfHook
  plugin.loaded! ActionPack::VERSION::STRING
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
immunio-1.1.6 lib/immunio/plugins/csrf.rb
immunio-1.1.5 lib/immunio/plugins/csrf.rb
immunio-1.1.2 lib/immunio/plugins/csrf.rb