Sha256: e731090f1afc9a58f7495bf4c7817d8982fcc640de560d668023bd252a2d8184

Contents?: true

Size: 1.22 KB

Versions: 9

Compression:

Stored size: 1.22 KB

Contents

# Copyright (c) 2015 Sqreen. All Rights Reserved.
# Please refer to our terms for more information: https://www.sqreen.com/terms.html

require 'sqreen/log'
require 'sqreen/exception'
require 'sqreen/actions/base'
require 'sqreen/actions/user_action_class'

module Sqreen
  module Actions
    # Redirects a user at the point Sqreen::identify()
    # or Sqreen::auth_track() are called
    class RedirectUser < Base
      extend UserActionClass

      self.type_name = 'redirect_user'

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

      def do_run(identity_params)
        Sqreen.log.info '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

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

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
sqreen-1.18.6-java lib/sqreen/actions/redirect_user.rb
sqreen-1.18.6 lib/sqreen/actions/redirect_user.rb
sqreen-1.18.5-java lib/sqreen/actions/redirect_user.rb
sqreen-1.18.5 lib/sqreen/actions/redirect_user.rb
sqreen-1.18.4-java lib/sqreen/actions/redirect_user.rb
sqreen-1.18.4 lib/sqreen/actions/redirect_user.rb
sqreen-1.18.3-java lib/sqreen/actions/redirect_user.rb
sqreen-1.18.3 lib/sqreen/actions/redirect_user.rb
sqreen-1.18.3.beta2 lib/sqreen/actions/redirect_user.rb