Sha256: 185c2babf6a858fdb6d426377822f47073b8e76581765179819da5af6555c3a1

Contents?: true

Size: 1.23 KB

Versions: 11

Compression:

Stored size: 1.23 KB

Contents

# typed: true

# 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.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

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

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
sqreen-1.22.0-java lib/sqreen/actions/redirect_user.rb
sqreen-1.22.0 lib/sqreen/actions/redirect_user.rb
sqreen-1.21.1-java lib/sqreen/actions/redirect_user.rb
sqreen-1.21.1 lib/sqreen/actions/redirect_user.rb
sqreen-1.21.0-java lib/sqreen/actions/redirect_user.rb
sqreen-1.21.0 lib/sqreen/actions/redirect_user.rb
sqreen-1.20.4-java lib/sqreen/actions/redirect_user.rb
sqreen-1.20.4 lib/sqreen/actions/redirect_user.rb
sqreen-1.21.0.beta3-java lib/sqreen/actions/redirect_user.rb
sqreen-1.21.0.beta3 lib/sqreen/actions/redirect_user.rb
sqreen-1.20.4.beta1 lib/sqreen/actions/redirect_user.rb