Class: Sqreen::Rules::DeviseAuthTrackCB
- Inherits:
-
RuleCB
- Object
- CB
- FrameworkCB
- RuleCB
- Sqreen::Rules::DeviseAuthTrackCB
- Defined in:
- lib/sqreen/rules/devise_auth_track_cb.rb
Constant Summary
Constants inherited from RuleCB
Constants included from CallCountable
CallCountable::COUNT_CALLS, CallCountable::FAILING, CallCountable::POST, CallCountable::PRE
Constants inherited from CB
Instance Attribute Summary
Attributes inherited from RuleCB
Attributes included from CallCountable
#call_count_interval, #call_counts
Attributes inherited from FrameworkCB
Attributes inherited from CB
#klass, #method, #overtimeable
Instance Method Summary collapse
-
#initialize(*args) ⇒ DeviseAuthTrackCB
constructor
A new instance of DeviseAuthTrackCB.
- #post(_rv, instance, _args, _budget) ⇒ Object
Methods inherited from RuleCB
#advise_action, #overtime!, #priority, #record_event, #record_exception, #rule_name, #rulespack_id
Methods included from CallCountable
#count_callback_calls, #failing_with_count, #post_with_count, #pre_with_count
Methods included from Conditionable
#condition_callbacks, #failing_with_conditions, #post_with_conditions, #pre_with_conditions
Methods inherited from FrameworkCB
#record_observation, #whitelisted?
Methods inherited from CB
#failing?, #framework, #overtime!, #post?, #pre?, #priority, #to_s, #whitelisted?
Constructor Details
#initialize(*args) ⇒ DeviseAuthTrackCB
Returns a new instance of DeviseAuthTrackCB.
13 14 15 16 |
# File 'lib/sqreen/rules/devise_auth_track_cb.rb', line 13 def initialize(*args) super(*args) @overtimeable = false end |
Instance Method Details
#post(_rv, instance, _args, _budget) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/sqreen/rules/devise_auth_track_cb.rb', line 18 def post(_rv, instance, _args, _budget) status = instance.instance_variable_get(:@result).to_s data = instance.authentication_hash keys = instance.send(:authentication_keys) ip = framework.client_ip category = status == 'failure' ? 'auto-login-fail' : 'auto-login-success' data = data.select { |k, _| keys.include?(k) } if data.empty? Sqreen.log.debug { "#{category} from #{ip} but keys empty" } return end payload = { keys: data.to_a, ip: ip } record_observation(category, JSON.dump(payload), 1) advise_action(nil) end |