Class: PxModule::PerimeterxCookieV1
- Inherits:
-
PerimeterxPayload
- Object
- PerimeterxPayload
- PxModule::PerimeterxCookieV1
- Defined in:
- lib/perimeterx/internal/payload/perimeter_x_cookie_v1.rb
Instance Attribute Summary collapse
-
#px_config ⇒ Object
Returns the value of attribute px_config.
-
#px_ctx ⇒ Object
Returns the value of attribute px_ctx.
Attributes inherited from PerimeterxPayload
#cookie_secret, #decoded_cookie, #px_cookie
Instance Method Summary collapse
- #cookie_block_action ⇒ Object
- #cookie_hmac ⇒ Object
- #cookie_score ⇒ Object
-
#initialize(px_config, px_ctx) ⇒ PerimeterxCookieV1
constructor
A new instance of PerimeterxCookieV1.
- #secured? ⇒ Boolean
- #valid_format?(cookie) ⇒ Boolean
Methods inherited from PerimeterxPayload
#cookie_time, #cookie_uuid, #cookie_vid, #decode, #decrypt, #deserialize, #expired?, #high_score?, #hmac_valid?, #is_valid?, px_cookie_factory, #secure_compare
Constructor Details
#initialize(px_config, px_ctx) ⇒ PerimeterxCookieV1
Returns a new instance of PerimeterxCookieV1.
6 7 8 9 10 11 12 |
# File 'lib/perimeterx/internal/payload/perimeter_x_cookie_v1.rb', line 6 def initialize(px_config, px_ctx) super(px_config) @px_ctx = px_ctx @px_cookie = px_ctx. @cookie_secret = px_config[:cookie_key] @logger.debug("PerimeterxCookieV1[initialize]") end |
Instance Attribute Details
#px_config ⇒ Object
Returns the value of attribute px_config.
4 5 6 |
# File 'lib/perimeterx/internal/payload/perimeter_x_cookie_v1.rb', line 4 def px_config @px_config end |
#px_ctx ⇒ Object
Returns the value of attribute px_ctx.
4 5 6 |
# File 'lib/perimeterx/internal/payload/perimeter_x_cookie_v1.rb', line 4 def px_ctx @px_ctx end |
Instance Method Details
#cookie_block_action ⇒ Object
26 27 28 |
# File 'lib/perimeterx/internal/payload/perimeter_x_cookie_v1.rb', line 26 def return 'c' end |
#cookie_hmac ⇒ Object
18 19 20 |
# File 'lib/perimeterx/internal/payload/perimeter_x_cookie_v1.rb', line 18 def return @decoded_cookie[:h] end |
#cookie_score ⇒ Object
14 15 16 |
# File 'lib/perimeterx/internal/payload/perimeter_x_cookie_v1.rb', line 14 def return @decoded_cookie[:s][:b] end |
#secured? ⇒ Boolean
30 31 32 33 34 35 36 37 38 |
# File 'lib/perimeterx/internal/payload/perimeter_x_cookie_v1.rb', line 30 def secured? base_hmac_str = "#{}#{@decoded_cookie[:s][:a]}#{}#{}#{}" hmac_str_withip = "#{base_hmac_str}#{@px_ctx.context[:ip]}#{@px_ctx.context[:user_agent]}" hmac_str_withoutip = "#{base_hmac_str}#{@px_ctx.context[:user_agent]}" return (hmac_valid?(hmac_str_withoutip, ) || hmac_valid?(hmac_str_withip, )) end |
#valid_format?(cookie) ⇒ Boolean
22 23 24 |
# File 'lib/perimeterx/internal/payload/perimeter_x_cookie_v1.rb', line 22 def valid_format?() return .key?(:t) && .key?(:s) && [:s].key?(:b) && .key?(:s) && .key?(:v) && .key?(:h) end |