From 8e9725bb17dceb8d3a400f2f907f37ecb2dac41a Mon Sep 17 00:00:00 2001 From: Ori Date: Thu, 28 Oct 2021 12:36:08 +0300 Subject: [PATCH 01/13] added bypass monitor header and aligned to spec --- px_metadata.json | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/px_metadata.json b/px_metadata.json index b077d10..e215de8 100644 --- a/px_metadata.json +++ b/px_metadata.json @@ -3,24 +3,25 @@ "supported_features": [ "additional_activity_handler", "advanced_blocking_response", - "batching_activities", + "batched_activities", "block_activity", "block_page_captcha", + "bypass_monitor_header", + "client_ip_extraction", "cookie_v3", "css_ref", "custom_logo", - "debug_mode", + "logger", + "filter_by_route", "first_party", - "ip_headers", "js_ref", - "mobile", - "module_enable_disable", - "monitor_mode", - "page_requested", - "pxvid", + "mobile_support", + "module_enable", + "module_mode", + "page_requested_activity", + "vid_extraction", "risk_api", "sensitive_headers", - "sensitive_routes", - "whitelist_routes" + "sensitive_routes" ] } \ No newline at end of file From 5f6c1cef25e1b7dc0f6fe74bb16bdc2415a0f431 Mon Sep 17 00:00:00 2001 From: OmerBacharPX Date: Thu, 20 Jan 2022 12:15:21 +0200 Subject: [PATCH 02/13] update px_metadata.json --- px_metadata.json | 1 + 1 file changed, 1 insertion(+) diff --git a/px_metadata.json b/px_metadata.json index e215de8..a322800 100644 --- a/px_metadata.json +++ b/px_metadata.json @@ -6,6 +6,7 @@ "batched_activities", "block_activity", "block_page_captcha", + "block_page_rate_limit", "bypass_monitor_header", "client_ip_extraction", "cookie_v3", From aec03ea0ef35a9f36054ae9b84f859bb5d6364ca Mon Sep 17 00:00:00 2001 From: Ori Date: Thu, 24 Feb 2022 16:10:53 +0200 Subject: [PATCH 03/13] new block page --- lib/perimeter_x.rb | 8 +- lib/perimeterx/utils/px_constants.rb | 2 + lib/perimeterx/utils/px_template_factory.rb | 2 +- .../utils/templates/block_template.mustache | 194 +++--------------- 4 files changed, 39 insertions(+), 167 deletions(-) diff --git a/lib/perimeter_x.rb b/lib/perimeter_x.rb index f45a2db..0f490be 100644 --- a/lib/perimeter_x.rb +++ b/lib/perimeter_x.rb @@ -56,18 +56,20 @@ def px_verify_request(request_config={}) end is_mobile = px_ctx.context[:cookie_origin] == 'header' ? '1' : '0' - action = px_ctx.context[:block_action][0,1] + action = px_ctx.context[:block_action][0,1] + block_script_uri = "/captcha.js?a=#{action}&u=#{px_ctx.context[:uuid]}&v=#{px_ctx.context[:vid]}&m=#{is_mobile}" + alt_block_script = "//#{PxModule::ALT_CAPTCHA_HOST}/#{px_config[:app_id]}#{block_script_uri}", if px_config[:first_party_enabled] px_template_object = { js_client_src: "/#{px_config[:app_id][2..-1]}/init.js", - block_script: "/#{px_config[:app_id][2..-1]}/captcha/#{px_config[:app_id]}/captcha.js?a=#{action}&u=#{px_ctx.context[:uuid]}&v=#{px_ctx.context[:vid]}&m=#{is_mobile}", + block_script: "/#{px_config[:app_id][2..-1]}/captcha/#{px_config[:app_id]}#{block_script_uri}", host_url: "/#{px_config[:app_id][2..-1]}/xhr" } else px_template_object = { js_client_src: "//#{PxModule::CLIENT_HOST}/#{px_config[:app_id]}/main.min.js", - block_script: "//#{PxModule::CAPTCHA_HOST}/#{px_config[:app_id]}/captcha.js?a=#{action}&u=#{px_ctx.context[:uuid]}&v=#{px_ctx.context[:vid]}&m=#{is_mobile}", + block_script: "//#{PxModule::CAPTCHA_HOST}/#{px_config[:app_id]}#{block_script_uri}", host_url: "https://collector-#{px_config[:app_id]}.perimeterx.net" } end diff --git a/lib/perimeterx/utils/px_constants.rb b/lib/perimeterx/utils/px_constants.rb index d86d1e7..2c16a75 100644 --- a/lib/perimeterx/utils/px_constants.rb +++ b/lib/perimeterx/utils/px_constants.rb @@ -41,6 +41,7 @@ module PxModule PROP_CSS_REF = :cssRef PROP_JS_REF = :jsRef PROP_BLOCK_SCRIPT = :blockScript + PROP_ALT_BLOCK_SCRIPT = :altBlockScript PROP_JS_CLIENT_SRC = :jsClientSrc PROP_HOST_URL = :hostUrl PROP_FIRST_PARTY_ENABLED = :firstPartyEnabled @@ -48,6 +49,7 @@ module PxModule # Hosts CLIENT_HOST = 'client.perimeterx.net' CAPTCHA_HOST = 'captcha.px-cdn.net' + ALT_CAPTCHA_HOST = 'captcha.px-cloud.net' VISIBLE = 'visible' HIDDEN = 'hidden' diff --git a/lib/perimeterx/utils/px_template_factory.rb b/lib/perimeterx/utils/px_template_factory.rb index acd5c82..9a5b3e4 100644 --- a/lib/perimeterx/utils/px_template_factory.rb +++ b/lib/perimeterx/utils/px_template_factory.rb @@ -23,7 +23,6 @@ def self.get_template(px_ctx, px_config, px_template_object) Mustache.template_file = "#{File.dirname(__FILE__) }/templates/#{template_type}#{PxModule::TEMPLATE_EXT}" view[PxModule::PROP_APP_ID] = px_config[:app_id] - view[PxModule::PROP_REF_ID] = px_ctx.context[:uuid] view[PxModule::PROP_VID] = px_ctx.context[:vid] view[PxModule::PROP_UUID] = px_ctx.context[:uuid] view[PxModule::PROP_CUSTOM_LOGO] = px_config[:custom_logo] @@ -32,6 +31,7 @@ def self.get_template(px_ctx, px_config, px_template_object) view[PxModule::PROP_HOST_URL] = px_template_object[:host_url] view[PxModule::PROP_LOGO_VISIBILITY] = px_config[:custom_logo] ? PxModule::VISIBLE : PxModule::HIDDEN view[PxModule::PROP_BLOCK_SCRIPT] = px_template_object[:block_script] + view[PxModule::PROP_ALT_BLOCK_SCRIPT] = px_template_object[:alt_block_script] view[PxModule::PROP_JS_CLIENT_SRC] = px_template_object[:js_client_src] view[PxModule::PROP_FIRST_PARTY_ENABLED] = px_ctx.context[:first_party_enabled] diff --git a/lib/perimeterx/utils/templates/block_template.mustache b/lib/perimeterx/utils/templates/block_template.mustache index 5352742..413911c 100644 --- a/lib/perimeterx/utils/templates/block_template.mustache +++ b/lib/perimeterx/utils/templates/block_template.mustache @@ -3,173 +3,41 @@ - Access to this page has been denied. - - - + + Access to this page has been denied {{#cssRef}} {{/cssRef}} - -
-
- -
-
-
-

Please verify you are a human

-
-
-
-
- -
-
-

- Access to this page has been denied because we believe you are using automation tools to browse the - website. -

-

- This may happen as a result of the following: -

-
    -
  • - Javascript is disabled or blocked by an extension (ad blockers for example) -
  • -
  • - Your browser does not support cookies -
  • -
-

- Please make sure that Javascript and cookies are enabled on your browser and that you are not blocking - them from loading. -

-

- Reference ID: #{{refId}} -

-
-
- -
- - - - - -{{#jsRef}} - -{{/jsRef}} + window._pxDisplayErrorMessage = function () { + var style = document.createElement('style'); + style.innerText = '@import url(https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&display=swap);body{background-color:#fafbfc}@media (max-width:480px){body{background-color:#fff}}.px-captcha-error-container{position:fixed;height:328px;background-color:#fff;font-family:Roboto,sans-serif}.px-captcha-error-header{color:#f0f1f2;font-size:29px;margin:67px 0 33px;font-weight:500;line-height:.83;text-align:center}.px-captcha-error-message{color:#f0f1f2;font-size:18px;margin:0 0 29px;line-height:1.33;text-align:center}div.px-captcha-error-button{text-align:center;line-height:50px;width:253px;margin:auto;border-radius:25px;border:solid 1px #f0f1f2;font-size:20px;color:#f0f1f2}div.px-captcha-error-wrapper{margin:23px 0 0}div.px-captcha-error{margin:auto;text-align:center;width:400px;height:30px;font-size:12px;background-color:#fcf0f2;color:#ce0e2d}img.px-captcha-error{margin:6px 10px -2px 0}@media (min-width:620px){.px-captcha-error-container{width:528px;top:50%;left:50%;margin-top:-164px;margin-left:-264px;border-radius:3px;box-shadow:0 2px 9px -1px rgba(0,0,0,.13)}}@media (min-width:481px) and (max-width:620px){.px-captcha-error-container{width:85%;top:50%;left:50%;margin-top:-164px;margin-left:-42.5%;border-radius:3px;box-shadow:0 2px 9px -1px rgba(0,0,0,.13)}}@media (max-width:480px){.px-captcha-error-container{width:528px;top:50%;left:50%;margin-top:-164px;margin-left:-264px}}'; + document.head.appendChild(style); + var div = document.createElement('div'); + div.className = 'px-captcha-error-container'; + div.innerHTML = '
Before we continue...
Press & Hold to confirm you are
a human (and not a bot).
Press & Hold
Please check your network connection or disable your ad-blocker.
'; + document.body.appendChild(div); + }; + + {{#jsRef}} + + {{/jsRef}} - + \ No newline at end of file From fa741d0d809c0869d8f32f55800ff3c6b1b491a6 Mon Sep 17 00:00:00 2001 From: Ori Date: Thu, 24 Feb 2022 16:30:32 +0200 Subject: [PATCH 04/13] adding in alt_block_script to template --- lib/perimeter_x.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/perimeter_x.rb b/lib/perimeter_x.rb index 0f490be..8d40749 100644 --- a/lib/perimeter_x.rb +++ b/lib/perimeter_x.rb @@ -64,13 +64,15 @@ def px_verify_request(request_config={}) px_template_object = { js_client_src: "/#{px_config[:app_id][2..-1]}/init.js", block_script: "/#{px_config[:app_id][2..-1]}/captcha/#{px_config[:app_id]}#{block_script_uri}", - host_url: "/#{px_config[:app_id][2..-1]}/xhr" + host_url: "/#{px_config[:app_id][2..-1]}/xhr", + alt_block_script: alt_block_script } else px_template_object = { js_client_src: "//#{PxModule::CLIENT_HOST}/#{px_config[:app_id]}/main.min.js", block_script: "//#{PxModule::CAPTCHA_HOST}/#{px_config[:app_id]}#{block_script_uri}", - host_url: "https://collector-#{px_config[:app_id]}.perimeterx.net" + host_url: "https://collector-#{px_config[:app_id]}.perimeterx.net", + alt_block_script: alt_block_script } end @@ -94,6 +96,7 @@ def px_verify_request(request_config={}) :vid => px_ctx.context[:vid], :hostUrl => "https://collector-#{px_config[:app_id]}.perimeterx.net", :blockScript => px_template_object[:block_script], + :altBlockScript => px_template_object[:alt_block_script] } render :json => hash_json From 850a75074dd5eb47ad8bd412239cb5b62de5e626 Mon Sep 17 00:00:00 2001 From: Ori Date: Thu, 24 Feb 2022 16:30:48 +0200 Subject: [PATCH 05/13] removing custom logo --- lib/perimeterx/configuration.rb | 1 - lib/perimeterx/utils/px_constants.rb | 2 -- lib/perimeterx/utils/px_template_factory.rb | 2 -- px_metadata.json | 1 - readme.md | 13 ------------- 5 files changed, 19 deletions(-) diff --git a/lib/perimeterx/configuration.rb b/lib/perimeterx/configuration.rb index 6f182fb..aafd277 100644 --- a/lib/perimeterx/configuration.rb +++ b/lib/perimeterx/configuration.rb @@ -58,7 +58,6 @@ class Configuration :risk_cookie_max_iterations => {types: [Integer], required: false}, :custom_verification_handler => {types: [Proc], required: false}, :additional_activity_handler => {types: [Proc], required: false}, - :custom_logo => {types: [String], required: false}, :css_ref => {types: [String], required: false}, :js_ref => {types: [String], required: false}, :custom_uri => {types: [Proc], required: false}, diff --git a/lib/perimeterx/utils/px_constants.rb b/lib/perimeterx/utils/px_constants.rb index 2c16a75..e4c349e 100644 --- a/lib/perimeterx/utils/px_constants.rb +++ b/lib/perimeterx/utils/px_constants.rb @@ -36,8 +36,6 @@ module PxModule PROP_APP_ID = :appId PROP_VID = :vid PROP_UUID = :uuid - PROP_LOGO_VISIBILITY = :logoVisibility - PROP_CUSTOM_LOGO = :customLogo PROP_CSS_REF = :cssRef PROP_JS_REF = :jsRef PROP_BLOCK_SCRIPT = :blockScript diff --git a/lib/perimeterx/utils/px_template_factory.rb b/lib/perimeterx/utils/px_template_factory.rb index 9a5b3e4..f272327 100644 --- a/lib/perimeterx/utils/px_template_factory.rb +++ b/lib/perimeterx/utils/px_template_factory.rb @@ -25,11 +25,9 @@ def self.get_template(px_ctx, px_config, px_template_object) view[PxModule::PROP_APP_ID] = px_config[:app_id] view[PxModule::PROP_VID] = px_ctx.context[:vid] view[PxModule::PROP_UUID] = px_ctx.context[:uuid] - view[PxModule::PROP_CUSTOM_LOGO] = px_config[:custom_logo] view[PxModule::PROP_CSS_REF] = px_config[:css_ref] view[PxModule::PROP_JS_REF] = px_config[:js_ref] view[PxModule::PROP_HOST_URL] = px_template_object[:host_url] - view[PxModule::PROP_LOGO_VISIBILITY] = px_config[:custom_logo] ? PxModule::VISIBLE : PxModule::HIDDEN view[PxModule::PROP_BLOCK_SCRIPT] = px_template_object[:block_script] view[PxModule::PROP_ALT_BLOCK_SCRIPT] = px_template_object[:alt_block_script] view[PxModule::PROP_JS_CLIENT_SRC] = px_template_object[:js_client_src] diff --git a/px_metadata.json b/px_metadata.json index a322800..1e042c3 100644 --- a/px_metadata.json +++ b/px_metadata.json @@ -11,7 +11,6 @@ "client_ip_extraction", "cookie_v3", "css_ref", - "custom_logo", "logger", "filter_by_route", "first_party", diff --git a/readme.md b/readme.md index 48c8189..efa7664 100644 --- a/readme.md +++ b/readme.md @@ -186,19 +186,6 @@ configuration = { ``` **Customizing Default Block Pages** -Adding a custom logo to the blocking page is by providing the `params` a key `custom_logo` , the logo will be displayed at the top div of the the block page The logo's `max-heigh` property would be `150px` and width would be set to `auto` - -The key custom_logo expects a valid URL address such as https://s.perimeterx.net/logo.png - -```ruby -params = [ - :app_id => 'APP_ID', - :cookie_key => 'COOKIE_SECRET', - :auth_token => 'AUTH_TOKEN', - :custom_logo => 'LOGO_URL' -]; -``` - **Custom JS/CSS** The block page can be modified with a custom CSS by adding to the `params` the key `css_ref` and providing a valid URL to the css In addition there is also the option to add a custom JS file by adding `js_ref` key to the pxConfig and providing the JS file that will be loaded with the block page, this key also expects a valid URL From eb5afa2d81bba7de22a85ae08480f40f1440418b Mon Sep 17 00:00:00 2001 From: Ori Date: Thu, 24 Feb 2022 17:11:40 +0200 Subject: [PATCH 06/13] minor fix --- lib/perimeter_x.rb | 5 ++--- lib/perimeterx/utils/px_template_factory.rb | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/perimeter_x.rb b/lib/perimeter_x.rb index 8d40749..7503b59 100644 --- a/lib/perimeter_x.rb +++ b/lib/perimeter_x.rb @@ -58,21 +58,20 @@ def px_verify_request(request_config={}) is_mobile = px_ctx.context[:cookie_origin] == 'header' ? '1' : '0' action = px_ctx.context[:block_action][0,1] block_script_uri = "/captcha.js?a=#{action}&u=#{px_ctx.context[:uuid]}&v=#{px_ctx.context[:vid]}&m=#{is_mobile}" - alt_block_script = "//#{PxModule::ALT_CAPTCHA_HOST}/#{px_config[:app_id]}#{block_script_uri}", if px_config[:first_party_enabled] px_template_object = { js_client_src: "/#{px_config[:app_id][2..-1]}/init.js", block_script: "/#{px_config[:app_id][2..-1]}/captcha/#{px_config[:app_id]}#{block_script_uri}", host_url: "/#{px_config[:app_id][2..-1]}/xhr", - alt_block_script: alt_block_script + alt_block_script: "//#{PxModule::ALT_CAPTCHA_HOST}/#{px_config[:app_id]}#{block_script_uri}" } else px_template_object = { js_client_src: "//#{PxModule::CLIENT_HOST}/#{px_config[:app_id]}/main.min.js", block_script: "//#{PxModule::CAPTCHA_HOST}/#{px_config[:app_id]}#{block_script_uri}", host_url: "https://collector-#{px_config[:app_id]}.perimeterx.net", - alt_block_script: alt_block_script + alt_block_script: "//#{PxModule::ALT_CAPTCHA_HOST}/#{px_config[:app_id]}#{block_script_uri}" } end diff --git a/lib/perimeterx/utils/px_template_factory.rb b/lib/perimeterx/utils/px_template_factory.rb index f272327..b1bbace 100644 --- a/lib/perimeterx/utils/px_template_factory.rb +++ b/lib/perimeterx/utils/px_template_factory.rb @@ -6,7 +6,7 @@ module PxTemplateFactory def self.get_template(px_ctx, px_config, px_template_object) logger = px_config[:logger] if (px_config[:challenge_enabled] && px_ctx.context[:block_action] == 'challenge') - logger.debug('PxTemplateFactory[get_template]: px challange triggered') + logger.debug('PxTemplateFactory[get_template]: px challenge triggered') return px_ctx.context[:block_action_data].html_safe end From 4fbf91f6acb29ea4f7b3158dd0190dbd46386016 Mon Sep 17 00:00:00 2001 From: Ori Date: Mon, 28 Feb 2022 12:29:23 +0200 Subject: [PATCH 07/13] Revert "removing custom logo" This reverts commit 850a75074dd5eb47ad8bd412239cb5b62de5e626. --- lib/perimeterx/configuration.rb | 1 + lib/perimeterx/utils/px_constants.rb | 2 ++ lib/perimeterx/utils/px_template_factory.rb | 2 ++ px_metadata.json | 1 + readme.md | 13 +++++++++++++ 5 files changed, 19 insertions(+) diff --git a/lib/perimeterx/configuration.rb b/lib/perimeterx/configuration.rb index aafd277..6f182fb 100644 --- a/lib/perimeterx/configuration.rb +++ b/lib/perimeterx/configuration.rb @@ -58,6 +58,7 @@ class Configuration :risk_cookie_max_iterations => {types: [Integer], required: false}, :custom_verification_handler => {types: [Proc], required: false}, :additional_activity_handler => {types: [Proc], required: false}, + :custom_logo => {types: [String], required: false}, :css_ref => {types: [String], required: false}, :js_ref => {types: [String], required: false}, :custom_uri => {types: [Proc], required: false}, diff --git a/lib/perimeterx/utils/px_constants.rb b/lib/perimeterx/utils/px_constants.rb index e4c349e..2c16a75 100644 --- a/lib/perimeterx/utils/px_constants.rb +++ b/lib/perimeterx/utils/px_constants.rb @@ -36,6 +36,8 @@ module PxModule PROP_APP_ID = :appId PROP_VID = :vid PROP_UUID = :uuid + PROP_LOGO_VISIBILITY = :logoVisibility + PROP_CUSTOM_LOGO = :customLogo PROP_CSS_REF = :cssRef PROP_JS_REF = :jsRef PROP_BLOCK_SCRIPT = :blockScript diff --git a/lib/perimeterx/utils/px_template_factory.rb b/lib/perimeterx/utils/px_template_factory.rb index b1bbace..b35b8c6 100644 --- a/lib/perimeterx/utils/px_template_factory.rb +++ b/lib/perimeterx/utils/px_template_factory.rb @@ -25,9 +25,11 @@ def self.get_template(px_ctx, px_config, px_template_object) view[PxModule::PROP_APP_ID] = px_config[:app_id] view[PxModule::PROP_VID] = px_ctx.context[:vid] view[PxModule::PROP_UUID] = px_ctx.context[:uuid] + view[PxModule::PROP_CUSTOM_LOGO] = px_config[:custom_logo] view[PxModule::PROP_CSS_REF] = px_config[:css_ref] view[PxModule::PROP_JS_REF] = px_config[:js_ref] view[PxModule::PROP_HOST_URL] = px_template_object[:host_url] + view[PxModule::PROP_LOGO_VISIBILITY] = px_config[:custom_logo] ? PxModule::VISIBLE : PxModule::HIDDEN view[PxModule::PROP_BLOCK_SCRIPT] = px_template_object[:block_script] view[PxModule::PROP_ALT_BLOCK_SCRIPT] = px_template_object[:alt_block_script] view[PxModule::PROP_JS_CLIENT_SRC] = px_template_object[:js_client_src] diff --git a/px_metadata.json b/px_metadata.json index 1e042c3..a322800 100644 --- a/px_metadata.json +++ b/px_metadata.json @@ -11,6 +11,7 @@ "client_ip_extraction", "cookie_v3", "css_ref", + "custom_logo", "logger", "filter_by_route", "first_party", diff --git a/readme.md b/readme.md index efa7664..48c8189 100644 --- a/readme.md +++ b/readme.md @@ -186,6 +186,19 @@ configuration = { ``` **Customizing Default Block Pages** +Adding a custom logo to the blocking page is by providing the `params` a key `custom_logo` , the logo will be displayed at the top div of the the block page The logo's `max-heigh` property would be `150px` and width would be set to `auto` + +The key custom_logo expects a valid URL address such as https://s.perimeterx.net/logo.png + +```ruby +params = [ + :app_id => 'APP_ID', + :cookie_key => 'COOKIE_SECRET', + :auth_token => 'AUTH_TOKEN', + :custom_logo => 'LOGO_URL' +]; +``` + **Custom JS/CSS** The block page can be modified with a custom CSS by adding to the `params` the key `css_ref` and providing a valid URL to the css In addition there is also the option to add a custom JS file by adding `js_ref` key to the pxConfig and providing the JS file that will be loaded with the block page, this key also expects a valid URL From 1546cc2d6d5beb208c3699d31c68df356fb2a3a0 Mon Sep 17 00:00:00 2001 From: Ori Date: Mon, 28 Feb 2022 12:30:07 +0200 Subject: [PATCH 08/13] adding custom logo, but not logo visibility back in --- lib/perimeterx/utils/px_constants.rb | 1 - lib/perimeterx/utils/px_template_factory.rb | 1 - lib/perimeterx/utils/templates/block_template.mustache | 1 + 3 files changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/perimeterx/utils/px_constants.rb b/lib/perimeterx/utils/px_constants.rb index 2c16a75..e71d0b0 100644 --- a/lib/perimeterx/utils/px_constants.rb +++ b/lib/perimeterx/utils/px_constants.rb @@ -36,7 +36,6 @@ module PxModule PROP_APP_ID = :appId PROP_VID = :vid PROP_UUID = :uuid - PROP_LOGO_VISIBILITY = :logoVisibility PROP_CUSTOM_LOGO = :customLogo PROP_CSS_REF = :cssRef PROP_JS_REF = :jsRef diff --git a/lib/perimeterx/utils/px_template_factory.rb b/lib/perimeterx/utils/px_template_factory.rb index b35b8c6..dc69e0b 100644 --- a/lib/perimeterx/utils/px_template_factory.rb +++ b/lib/perimeterx/utils/px_template_factory.rb @@ -29,7 +29,6 @@ def self.get_template(px_ctx, px_config, px_template_object) view[PxModule::PROP_CSS_REF] = px_config[:css_ref] view[PxModule::PROP_JS_REF] = px_config[:js_ref] view[PxModule::PROP_HOST_URL] = px_template_object[:host_url] - view[PxModule::PROP_LOGO_VISIBILITY] = px_config[:custom_logo] ? PxModule::VISIBLE : PxModule::HIDDEN view[PxModule::PROP_BLOCK_SCRIPT] = px_template_object[:block_script] view[PxModule::PROP_ALT_BLOCK_SCRIPT] = px_template_object[:alt_block_script] view[PxModule::PROP_JS_CLIENT_SRC] = px_template_object[:js_client_src] diff --git a/lib/perimeterx/utils/templates/block_template.mustache b/lib/perimeterx/utils/templates/block_template.mustache index 413911c..64cf059 100644 --- a/lib/perimeterx/utils/templates/block_template.mustache +++ b/lib/perimeterx/utils/templates/block_template.mustache @@ -14,6 +14,7 @@ window._pxVid = '{{vid}}'; window._pxUuid = '{{uuid}}'; window._pxAppId = '{{appId}}'; + window._pxCustomLogo = '{{customLogo}}'; window._pxHostUrl = '{{hostUrl}}'; window._pxJsClientSrc = '{{jsClientSrc}}'; window._pxFirstPartyEnabled = {{firstPartyEnabled}}; From d6958e5d3c3e54a4b4f7e3492f3448764c44fc66 Mon Sep 17 00:00:00 2001 From: ori-gold-px <77228321+ori-gold-px@users.noreply.github.com> Date: Wed, 9 Mar 2022 18:14:14 +0200 Subject: [PATCH 09/13] Revert "[SDKNEW-1656] Feature/new block page" --- lib/perimeter_x.rb | 14 +- lib/perimeterx/utils/px_constants.rb | 3 +- lib/perimeterx/utils/px_template_factory.rb | 5 +- .../utils/templates/block_template.mustache | 195 +++++++++++++++--- 4 files changed, 172 insertions(+), 45 deletions(-) diff --git a/lib/perimeter_x.rb b/lib/perimeter_x.rb index 7503b59..f45a2db 100644 --- a/lib/perimeter_x.rb +++ b/lib/perimeter_x.rb @@ -56,22 +56,19 @@ def px_verify_request(request_config={}) end is_mobile = px_ctx.context[:cookie_origin] == 'header' ? '1' : '0' - action = px_ctx.context[:block_action][0,1] - block_script_uri = "/captcha.js?a=#{action}&u=#{px_ctx.context[:uuid]}&v=#{px_ctx.context[:vid]}&m=#{is_mobile}" + action = px_ctx.context[:block_action][0,1] if px_config[:first_party_enabled] px_template_object = { js_client_src: "/#{px_config[:app_id][2..-1]}/init.js", - block_script: "/#{px_config[:app_id][2..-1]}/captcha/#{px_config[:app_id]}#{block_script_uri}", - host_url: "/#{px_config[:app_id][2..-1]}/xhr", - alt_block_script: "//#{PxModule::ALT_CAPTCHA_HOST}/#{px_config[:app_id]}#{block_script_uri}" + block_script: "/#{px_config[:app_id][2..-1]}/captcha/#{px_config[:app_id]}/captcha.js?a=#{action}&u=#{px_ctx.context[:uuid]}&v=#{px_ctx.context[:vid]}&m=#{is_mobile}", + host_url: "/#{px_config[:app_id][2..-1]}/xhr" } else px_template_object = { js_client_src: "//#{PxModule::CLIENT_HOST}/#{px_config[:app_id]}/main.min.js", - block_script: "//#{PxModule::CAPTCHA_HOST}/#{px_config[:app_id]}#{block_script_uri}", - host_url: "https://collector-#{px_config[:app_id]}.perimeterx.net", - alt_block_script: "//#{PxModule::ALT_CAPTCHA_HOST}/#{px_config[:app_id]}#{block_script_uri}" + block_script: "//#{PxModule::CAPTCHA_HOST}/#{px_config[:app_id]}/captcha.js?a=#{action}&u=#{px_ctx.context[:uuid]}&v=#{px_ctx.context[:vid]}&m=#{is_mobile}", + host_url: "https://collector-#{px_config[:app_id]}.perimeterx.net" } end @@ -95,7 +92,6 @@ def px_verify_request(request_config={}) :vid => px_ctx.context[:vid], :hostUrl => "https://collector-#{px_config[:app_id]}.perimeterx.net", :blockScript => px_template_object[:block_script], - :altBlockScript => px_template_object[:alt_block_script] } render :json => hash_json diff --git a/lib/perimeterx/utils/px_constants.rb b/lib/perimeterx/utils/px_constants.rb index e71d0b0..d86d1e7 100644 --- a/lib/perimeterx/utils/px_constants.rb +++ b/lib/perimeterx/utils/px_constants.rb @@ -36,11 +36,11 @@ module PxModule PROP_APP_ID = :appId PROP_VID = :vid PROP_UUID = :uuid + PROP_LOGO_VISIBILITY = :logoVisibility PROP_CUSTOM_LOGO = :customLogo PROP_CSS_REF = :cssRef PROP_JS_REF = :jsRef PROP_BLOCK_SCRIPT = :blockScript - PROP_ALT_BLOCK_SCRIPT = :altBlockScript PROP_JS_CLIENT_SRC = :jsClientSrc PROP_HOST_URL = :hostUrl PROP_FIRST_PARTY_ENABLED = :firstPartyEnabled @@ -48,7 +48,6 @@ module PxModule # Hosts CLIENT_HOST = 'client.perimeterx.net' CAPTCHA_HOST = 'captcha.px-cdn.net' - ALT_CAPTCHA_HOST = 'captcha.px-cloud.net' VISIBLE = 'visible' HIDDEN = 'hidden' diff --git a/lib/perimeterx/utils/px_template_factory.rb b/lib/perimeterx/utils/px_template_factory.rb index dc69e0b..acd5c82 100644 --- a/lib/perimeterx/utils/px_template_factory.rb +++ b/lib/perimeterx/utils/px_template_factory.rb @@ -6,7 +6,7 @@ module PxTemplateFactory def self.get_template(px_ctx, px_config, px_template_object) logger = px_config[:logger] if (px_config[:challenge_enabled] && px_ctx.context[:block_action] == 'challenge') - logger.debug('PxTemplateFactory[get_template]: px challenge triggered') + logger.debug('PxTemplateFactory[get_template]: px challange triggered') return px_ctx.context[:block_action_data].html_safe end @@ -23,14 +23,15 @@ def self.get_template(px_ctx, px_config, px_template_object) Mustache.template_file = "#{File.dirname(__FILE__) }/templates/#{template_type}#{PxModule::TEMPLATE_EXT}" view[PxModule::PROP_APP_ID] = px_config[:app_id] + view[PxModule::PROP_REF_ID] = px_ctx.context[:uuid] view[PxModule::PROP_VID] = px_ctx.context[:vid] view[PxModule::PROP_UUID] = px_ctx.context[:uuid] view[PxModule::PROP_CUSTOM_LOGO] = px_config[:custom_logo] view[PxModule::PROP_CSS_REF] = px_config[:css_ref] view[PxModule::PROP_JS_REF] = px_config[:js_ref] view[PxModule::PROP_HOST_URL] = px_template_object[:host_url] + view[PxModule::PROP_LOGO_VISIBILITY] = px_config[:custom_logo] ? PxModule::VISIBLE : PxModule::HIDDEN view[PxModule::PROP_BLOCK_SCRIPT] = px_template_object[:block_script] - view[PxModule::PROP_ALT_BLOCK_SCRIPT] = px_template_object[:alt_block_script] view[PxModule::PROP_JS_CLIENT_SRC] = px_template_object[:js_client_src] view[PxModule::PROP_FIRST_PARTY_ENABLED] = px_ctx.context[:first_party_enabled] diff --git a/lib/perimeterx/utils/templates/block_template.mustache b/lib/perimeterx/utils/templates/block_template.mustache index 64cf059..5352742 100644 --- a/lib/perimeterx/utils/templates/block_template.mustache +++ b/lib/perimeterx/utils/templates/block_template.mustache @@ -3,42 +3,173 @@ - - Access to this page has been denied + Access to this page has been denied. + + + {{#cssRef}} {{/cssRef}} + - + - {{#jsRef}} - - {{/jsRef}} + } + + + +{{#jsRef}} + +{{/jsRef}} - \ No newline at end of file + From 5d0728b886b9c0b6f778ced3f25c21a3f6f77d88 Mon Sep 17 00:00:00 2001 From: Ori Date: Sun, 10 Apr 2022 14:28:40 +0300 Subject: [PATCH 10/13] added custom logo to abr response --- lib/perimeter_x.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/perimeter_x.rb b/lib/perimeter_x.rb index f45a2db..1924e96 100644 --- a/lib/perimeter_x.rb +++ b/lib/perimeter_x.rb @@ -92,6 +92,8 @@ def px_verify_request(request_config={}) :vid => px_ctx.context[:vid], :hostUrl => "https://collector-#{px_config[:app_id]}.perimeterx.net", :blockScript => px_template_object[:block_script], + :altBlockScript => px_template_object[:alt_block_script], + :customLogo => px_config[:custom_logo] } render :json => hash_json From 60395e884fbd96b90f381bc046ce90139c795230 Mon Sep 17 00:00:00 2001 From: Ori Date: Sun, 10 Apr 2022 15:03:27 +0300 Subject: [PATCH 11/13] updated changelog --- changelog.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/changelog.md b/changelog.md index 2839769..aa3286e 100644 --- a/changelog.md +++ b/changelog.md @@ -5,6 +5,16 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). +## [] - + +### Added + +- Custom logo in block JSON response + +### Changed + +- Updated block page to use new template + ## [2.2.1] - 2020-09-27 ### Fixed - bypass_monitor_header type validation From f8164aa5c7214662180c149a6ceb44f317be221c Mon Sep 17 00:00:00 2001 From: Ori Date: Sun, 10 Apr 2022 15:07:44 +0300 Subject: [PATCH 12/13] Revert "Revert "[SDKNEW-1656] Feature/new block page"" This reverts commit d6958e5d3c3e54a4b4f7e3492f3448764c44fc66. --- lib/perimeter_x.rb | 13 +- lib/perimeterx/utils/px_constants.rb | 3 +- lib/perimeterx/utils/px_template_factory.rb | 5 +- .../utils/templates/block_template.mustache | 195 +++--------------- 4 files changed, 44 insertions(+), 172 deletions(-) diff --git a/lib/perimeter_x.rb b/lib/perimeter_x.rb index 1924e96..80c9729 100644 --- a/lib/perimeter_x.rb +++ b/lib/perimeter_x.rb @@ -56,19 +56,22 @@ def px_verify_request(request_config={}) end is_mobile = px_ctx.context[:cookie_origin] == 'header' ? '1' : '0' - action = px_ctx.context[:block_action][0,1] + action = px_ctx.context[:block_action][0,1] + block_script_uri = "/captcha.js?a=#{action}&u=#{px_ctx.context[:uuid]}&v=#{px_ctx.context[:vid]}&m=#{is_mobile}" if px_config[:first_party_enabled] px_template_object = { js_client_src: "/#{px_config[:app_id][2..-1]}/init.js", - block_script: "/#{px_config[:app_id][2..-1]}/captcha/#{px_config[:app_id]}/captcha.js?a=#{action}&u=#{px_ctx.context[:uuid]}&v=#{px_ctx.context[:vid]}&m=#{is_mobile}", - host_url: "/#{px_config[:app_id][2..-1]}/xhr" + block_script: "/#{px_config[:app_id][2..-1]}/captcha/#{px_config[:app_id]}#{block_script_uri}", + host_url: "/#{px_config[:app_id][2..-1]}/xhr", + alt_block_script: "//#{PxModule::ALT_CAPTCHA_HOST}/#{px_config[:app_id]}#{block_script_uri}" } else px_template_object = { js_client_src: "//#{PxModule::CLIENT_HOST}/#{px_config[:app_id]}/main.min.js", - block_script: "//#{PxModule::CAPTCHA_HOST}/#{px_config[:app_id]}/captcha.js?a=#{action}&u=#{px_ctx.context[:uuid]}&v=#{px_ctx.context[:vid]}&m=#{is_mobile}", - host_url: "https://collector-#{px_config[:app_id]}.perimeterx.net" + block_script: "//#{PxModule::CAPTCHA_HOST}/#{px_config[:app_id]}#{block_script_uri}", + host_url: "https://collector-#{px_config[:app_id]}.perimeterx.net", + alt_block_script: "//#{PxModule::ALT_CAPTCHA_HOST}/#{px_config[:app_id]}#{block_script_uri}" } end diff --git a/lib/perimeterx/utils/px_constants.rb b/lib/perimeterx/utils/px_constants.rb index d86d1e7..e71d0b0 100644 --- a/lib/perimeterx/utils/px_constants.rb +++ b/lib/perimeterx/utils/px_constants.rb @@ -36,11 +36,11 @@ module PxModule PROP_APP_ID = :appId PROP_VID = :vid PROP_UUID = :uuid - PROP_LOGO_VISIBILITY = :logoVisibility PROP_CUSTOM_LOGO = :customLogo PROP_CSS_REF = :cssRef PROP_JS_REF = :jsRef PROP_BLOCK_SCRIPT = :blockScript + PROP_ALT_BLOCK_SCRIPT = :altBlockScript PROP_JS_CLIENT_SRC = :jsClientSrc PROP_HOST_URL = :hostUrl PROP_FIRST_PARTY_ENABLED = :firstPartyEnabled @@ -48,6 +48,7 @@ module PxModule # Hosts CLIENT_HOST = 'client.perimeterx.net' CAPTCHA_HOST = 'captcha.px-cdn.net' + ALT_CAPTCHA_HOST = 'captcha.px-cloud.net' VISIBLE = 'visible' HIDDEN = 'hidden' diff --git a/lib/perimeterx/utils/px_template_factory.rb b/lib/perimeterx/utils/px_template_factory.rb index acd5c82..dc69e0b 100644 --- a/lib/perimeterx/utils/px_template_factory.rb +++ b/lib/perimeterx/utils/px_template_factory.rb @@ -6,7 +6,7 @@ module PxTemplateFactory def self.get_template(px_ctx, px_config, px_template_object) logger = px_config[:logger] if (px_config[:challenge_enabled] && px_ctx.context[:block_action] == 'challenge') - logger.debug('PxTemplateFactory[get_template]: px challange triggered') + logger.debug('PxTemplateFactory[get_template]: px challenge triggered') return px_ctx.context[:block_action_data].html_safe end @@ -23,15 +23,14 @@ def self.get_template(px_ctx, px_config, px_template_object) Mustache.template_file = "#{File.dirname(__FILE__) }/templates/#{template_type}#{PxModule::TEMPLATE_EXT}" view[PxModule::PROP_APP_ID] = px_config[:app_id] - view[PxModule::PROP_REF_ID] = px_ctx.context[:uuid] view[PxModule::PROP_VID] = px_ctx.context[:vid] view[PxModule::PROP_UUID] = px_ctx.context[:uuid] view[PxModule::PROP_CUSTOM_LOGO] = px_config[:custom_logo] view[PxModule::PROP_CSS_REF] = px_config[:css_ref] view[PxModule::PROP_JS_REF] = px_config[:js_ref] view[PxModule::PROP_HOST_URL] = px_template_object[:host_url] - view[PxModule::PROP_LOGO_VISIBILITY] = px_config[:custom_logo] ? PxModule::VISIBLE : PxModule::HIDDEN view[PxModule::PROP_BLOCK_SCRIPT] = px_template_object[:block_script] + view[PxModule::PROP_ALT_BLOCK_SCRIPT] = px_template_object[:alt_block_script] view[PxModule::PROP_JS_CLIENT_SRC] = px_template_object[:js_client_src] view[PxModule::PROP_FIRST_PARTY_ENABLED] = px_ctx.context[:first_party_enabled] diff --git a/lib/perimeterx/utils/templates/block_template.mustache b/lib/perimeterx/utils/templates/block_template.mustache index 5352742..64cf059 100644 --- a/lib/perimeterx/utils/templates/block_template.mustache +++ b/lib/perimeterx/utils/templates/block_template.mustache @@ -3,173 +3,42 @@ - Access to this page has been denied. - - - + + Access to this page has been denied {{#cssRef}} {{/cssRef}} - -
-
- -
-
-
-

Please verify you are a human

-
-
-
-
- -
-
-

- Access to this page has been denied because we believe you are using automation tools to browse the - website. -

-

- This may happen as a result of the following: -

-
    -
  • - Javascript is disabled or blocked by an extension (ad blockers for example) -
  • -
  • - Your browser does not support cookies -
  • -
-

- Please make sure that Javascript and cookies are enabled on your browser and that you are not blocking - them from loading. -

-

- Reference ID: #{{refId}} -

-
-
- -
- - - - - -{{#jsRef}} - -{{/jsRef}} + window._pxDisplayErrorMessage = function () { + var style = document.createElement('style'); + style.innerText = '@import url(https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&display=swap);body{background-color:#fafbfc}@media (max-width:480px){body{background-color:#fff}}.px-captcha-error-container{position:fixed;height:328px;background-color:#fff;font-family:Roboto,sans-serif}.px-captcha-error-header{color:#f0f1f2;font-size:29px;margin:67px 0 33px;font-weight:500;line-height:.83;text-align:center}.px-captcha-error-message{color:#f0f1f2;font-size:18px;margin:0 0 29px;line-height:1.33;text-align:center}div.px-captcha-error-button{text-align:center;line-height:50px;width:253px;margin:auto;border-radius:25px;border:solid 1px #f0f1f2;font-size:20px;color:#f0f1f2}div.px-captcha-error-wrapper{margin:23px 0 0}div.px-captcha-error{margin:auto;text-align:center;width:400px;height:30px;font-size:12px;background-color:#fcf0f2;color:#ce0e2d}img.px-captcha-error{margin:6px 10px -2px 0}@media (min-width:620px){.px-captcha-error-container{width:528px;top:50%;left:50%;margin-top:-164px;margin-left:-264px;border-radius:3px;box-shadow:0 2px 9px -1px rgba(0,0,0,.13)}}@media (min-width:481px) and (max-width:620px){.px-captcha-error-container{width:85%;top:50%;left:50%;margin-top:-164px;margin-left:-42.5%;border-radius:3px;box-shadow:0 2px 9px -1px rgba(0,0,0,.13)}}@media (max-width:480px){.px-captcha-error-container{width:528px;top:50%;left:50%;margin-top:-164px;margin-left:-264px}}'; + document.head.appendChild(style); + var div = document.createElement('div'); + div.className = 'px-captcha-error-container'; + div.innerHTML = '
Before we continue...
Press & Hold to confirm you are
a human (and not a bot).
Press & Hold
Please check your network connection or disable your ad-blocker.
'; + document.body.appendChild(div); + }; + + {{#jsRef}} + + {{/jsRef}} - + \ No newline at end of file From accf133f48ae200901e60b31a95a9a6b1d4b75cc Mon Sep 17 00:00:00 2001 From: Ori Date: Sun, 10 Apr 2022 16:26:01 +0300 Subject: [PATCH 13/13] release v2.3.0 --- LICENSE.txt | 2 +- changelog.md | 2 +- lib/perimeterx/version.rb | 2 +- px_metadata.json | 2 +- readme.md | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/LICENSE.txt b/LICENSE.txt index 6d1d71c..7089bfd 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,4 +1,4 @@ -Copyright © 2016 PerimeterX, Inc. +Copyright © 2022 PerimeterX, Inc. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/changelog.md b/changelog.md index aa3286e..6c101e4 100644 --- a/changelog.md +++ b/changelog.md @@ -5,7 +5,7 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). -## [] - +## [2.3.0] - 2022-04-10 ### Added diff --git a/lib/perimeterx/version.rb b/lib/perimeterx/version.rb index 4a5ab30..cc0ca06 100644 --- a/lib/perimeterx/version.rb +++ b/lib/perimeterx/version.rb @@ -1,3 +1,3 @@ module PxModule - VERSION = '2.2.1' + VERSION = '2.3.0' end diff --git a/px_metadata.json b/px_metadata.json index a322800..d2a18de 100644 --- a/px_metadata.json +++ b/px_metadata.json @@ -1,5 +1,5 @@ { - "version": "2.2.1", + "version": "2.3.0", "supported_features": [ "additional_activity_handler", "advanced_blocking_response", diff --git a/readme.md b/readme.md index 48c8189..2b064e4 100644 --- a/readme.md +++ b/readme.md @@ -5,7 +5,7 @@ [PerimeterX](http://www.perimeterx.com) Ruby SDK ============================================================= -> Latest stable version: [v2.2.1](https://rubygems.org/gems/perimeter_x) +> Latest stable version: [v2.3.0](https://rubygems.org/gems/perimeter_x) Table of Contents -----------------