Sha256: dc5965e1bf2933d0cf5b06dddfa8f5ea01938e5f0b36d6af4c60ae17d7fa4210

Contents?: true

Size: 1.24 KB

Versions: 10

Compression:

Stored size: 1.24 KB

Contents

# typed: ignore

# 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

10 entries across 10 versions & 1 rubygems

Version Path
sqreen-1.25.1 lib/sqreen/actions/redirect_user.rb
sqreen-1.25.0 lib/sqreen/actions/redirect_user.rb
sqreen-1.24.3 lib/sqreen/actions/redirect_user.rb
sqreen-1.24.2 lib/sqreen/actions/redirect_user.rb
sqreen-1.24.1 lib/sqreen/actions/redirect_user.rb
sqreen-1.24.0 lib/sqreen/actions/redirect_user.rb
sqreen-1.23.2 lib/sqreen/actions/redirect_user.rb
sqreen-1.23.1 lib/sqreen/actions/redirect_user.rb
sqreen-1.23.0 lib/sqreen/actions/redirect_user.rb
sqreen-1.22.1 lib/sqreen/actions/redirect_user.rb