Module: Immunio::CookieHooks

Extended by:
ActiveSupport::Concern
Defined in:
lib/immunio/plugins/action_dispatch.rb

Instance Method Summary collapse

Instance Method Details

#lookup_with_immunio(name) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/immunio/plugins/action_dispatch.rb', line 15

def lookup_with_immunio(name)
  Request.time "plugin", "#{Module.nesting[0]}::#{__method__}" do
    cookie_name = (Rails::VERSION::MAJOR > 4) ? name.to_s : name
    raw_cookie_value = @parent_jar[cookie_name]

    cookie_value = Request.pause(
      'plugin',
      "#{Module.nesting[0]}::#{__method__}") do
      lookup_without_immunio(name)
    end

    if !raw_cookie_value.nil? and cookie_value.nil?
      Immunio.run_hook!(
        'action_dispatch',
        'bad_cookie',
        key: cookie_name,
        value: raw_cookie_value)
    end

    cookie_value
  end
end