Class: PxModule::PerimeterX
- Inherits:
-
Object
- Object
- PxModule::PerimeterX
- Defined in:
- lib/perimeter_x.rb
Overview
PerimeterX Module
Constant Summary collapse
- @@__instance =
nil- @@mutex =
Mutex.new
Instance Attribute Summary collapse
-
#px_activity_client ⇒ Object
Returns the value of attribute px_activity_client.
-
#px_config ⇒ Object
readonly
Returns the value of attribute px_config.
-
#px_http_client ⇒ Object
Returns the value of attribute px_http_client.
Class Method Summary collapse
-
.configure(params) ⇒ Object
Static methods.
- .instance ⇒ Object
Instance Method Summary collapse
-
#verify(env) ⇒ Object
Instance Methods.
Instance Attribute Details
#px_activity_client ⇒ Object
Returns the value of attribute px_activity_client.
71 72 73 |
# File 'lib/perimeter_x.rb', line 71 def px_activity_client @px_activity_client end |
#px_config ⇒ Object (readonly)
Returns the value of attribute px_config.
69 70 71 |
# File 'lib/perimeter_x.rb', line 69 def px_config @px_config end |
#px_http_client ⇒ Object
Returns the value of attribute px_http_client.
70 71 72 |
# File 'lib/perimeter_x.rb', line 70 def px_http_client @px_http_client end |
Class Method Details
.configure(params) ⇒ Object
Static methods
74 75 76 77 78 79 80 81 |
# File 'lib/perimeter_x.rb', line 74 def self.configure(params) return true if @@__instance @@mutex.synchronize { return @@__instance if @@__instance @@__instance = new(params) } return true end |
.instance ⇒ Object
83 84 85 86 |
# File 'lib/perimeter_x.rb', line 83 def self.instance return @@__instance if !@@__instance.nil? raise Exception.new('Please initialize perimeter x first') end |
Instance Method Details
#verify(env) ⇒ Object
Instance Methods
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/perimeter_x.rb', line 90 def verify(env) begin @logger.debug('PerimeterX[pxVerify]') if (!@px_config[:module_enabled]) @logger.warn('Module is disabled') return true end req = ActionDispatch::Request.new(env) px_ctx = PerimeterXContext.new(@px_config, req) # Captcha phase captcha_verified, px_ctx = @px_captcha_validator.verify(px_ctx) if (captcha_verified) return handle_verification(px_ctx) end # Cookie phase , px_ctx = .verify(px_ctx) if (!) @px_s2s_validator.verify(px_ctx) end if (@px_config.key?(:custom_verification_handler)) return @px_config[:custom_verification_handler].call(px_ctx.context) else return handle_verification(px_ctx) end rescue Exception => e @logger.error("#{e.backtrace.first}: #{e.message} (#{e.class})") e.backtrace.drop(1).map {|s| @logger.error("\t#{s}")} return true end end |