Class: PxModule::PerimeterX
- Inherits:
-
Object
- Object
- PxModule::PerimeterX
- Defined in:
- lib/perimeter_x.rb
Overview
PerimtereX 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.
51 52 53 |
# File 'lib/perimeter_x.rb', line 51 def px_activity_client @px_activity_client end |
#px_config ⇒ Object (readonly)
Returns the value of attribute px_config.
49 50 51 |
# File 'lib/perimeter_x.rb', line 49 def px_config @px_config end |
#px_http_client ⇒ Object
Returns the value of attribute px_http_client.
50 51 52 |
# File 'lib/perimeter_x.rb', line 50 def px_http_client @px_http_client end |
Class Method Details
.configure(params) ⇒ Object
Static methods
54 55 56 57 58 59 60 61 |
# File 'lib/perimeter_x.rb', line 54 def self.configure(params) return true if @@__instance @@mutex.synchronize { return @@__instance if @@__instance @@__instance = new(params) } return true end |
.instance ⇒ Object
63 64 65 66 |
# File 'lib/perimeter_x.rb', line 63 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
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/perimeter_x.rb', line 70 def verify(env) begin @logger.debug("PerimeterX[pxVerify]") req = ActionDispatch::Request.new(env) if (!@px_config[:module_enabled]) @logger.warn("Module is disabled") return true end 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 |