Class: Sqreen::Actions::RedirectUser

Inherits:
Base
  • Object
show all
Extended by:
UserActionClass
Defined in:
lib/sqreen/actions/redirect_user.rb

Overview

Redirects a user at the point Sqreen::identify() or Sqreen::auth_track() are called

Instance Attribute Summary

Attributes inherited from Base

#expiry, #id, #send_response

Instance Method Summary collapse

Methods included from UserActionClass

new_index

Methods inherited from Base

get_type_class, inherited, known_subclasses, known_types, new_index, #run

Constructor Details

#initialize(id, opts, params = {}) ⇒ RedirectUser

Returns a new instance of RedirectUser.



20
21
22
23
24
# File 'lib/sqreen/actions/redirect_user.rb', line 20

def initialize(id, opts, params = {})
  super(id, opts)
  @redirect_url = params['url']
  raise "no url provided for action #{id}" unless @redirect_url
end

Instance Method Details

#do_run(identity_params) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/sqreen/actions/redirect_user.rb', line 26

def do_run(identity_params)
  Sqreen.log.debug 'Will request redirect for user with identity ' \
    "#{identity_params} (action: #{id})."

  e = Sqreen::AttackBlocked.new(
    "Redirected user with identity #{identity_params} " \
    'due to automatic security response. No action is required'
  )
  e.redirect_url = @redirect_url

  {
    :status => :raise,
    :exception => e,
  }
end

#event_properties(identity_params) ⇒ Object



42
43
44
# File 'lib/sqreen/actions/redirect_user.rb', line 42

def event_properties(identity_params)
  { 'user' => identity_params }
end