bot_challenge_page 1.2.0 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e9bab69af841c919b3b1f86fe7b2a955336b5f32628b8f285cb30a46ae66864d
4
- data.tar.gz: 92ba43d7c776cd7dfa9e73299d8872d0d9720e0056483ff91dbd98a6f3033303
3
+ metadata.gz: 84489b3222b7f78c52f1d952362c0105c3bbd0973311e7847246ae2182b42eac
4
+ data.tar.gz: 99bfc469263b9bc6101733e864273e7a956ececa7c66f41ee52f163257518be3
5
5
  SHA512:
6
- metadata.gz: 382303ff3e535338d0e0ad1cc865e76654b29f0632dd1c37324a27f58e05697687bde0699efcc13e6cb05d19b317cc730b33797fc0a6db05581ffc8fbc61ce17
7
- data.tar.gz: 663f8a44261025faf00eab1f0748b5888c03af5273000af89022ce7ed343882a7e03655f27e339084aeff9fd07009910609a05e48a39f97106a48b01ac34b803
6
+ metadata.gz: 7bee70170d8b41a3b431cef8d706d4f34ed28a8f48ab6b82d268fe37c5fcfbfb5bfeae9835bb70afb655b57137e81d0f034204a7ea4deef30b63a130a9218874
7
+ data.tar.gz: ac1b97fa558e63c3a3128d46dabf563af13ec0def315ed98454f9c7328f3299a6c07f91fd1c68b0c792304a05d4778038ebcd1edd2131d885bb10469751c4249
@@ -49,11 +49,12 @@ module BotChallengePage
49
49
  end
50
50
  end
51
51
 
52
- # Does the session already contain a bot detect pass that is good for this request
53
- # Tie to IP address to prevent session replay shared among IPs
54
- def _bot_detect_passed_good?(controller)
55
- request = controller.request
56
-
52
+ # Does the session already contain a bot detect pass that is good for this request?
53
+ #
54
+ # Does make sure any cookie/session pass is valid for this client/request and not
55
+ # expired.
56
+ #
57
+ def bot_challenge_passed?(request)
57
58
  session_data = request.session[self.bot_challenge_config.session_passed_key]
58
59
 
59
60
  return false unless session_data && session_data.kind_of?(Hash)
@@ -63,9 +64,17 @@ module BotChallengePage
63
64
  fingerprint = session_data[self::SESSION_FINGERPRINT_KEY]
64
65
 
65
66
  (Time.now - Time.iso8601(datetime) < self.bot_challenge_config.session_passed_good_for ) &&
66
- (fingerprint == self.bot_challenge_config.session_valid_fingerprint.call(request)) &&
67
- # not a real condition, just to call our hook on passed
68
- (controller.instance_exec(self, &self.bot_challenge_config.after_session_passed) || true)
67
+ (fingerprint == self.bot_challenge_config.session_valid_fingerprint.call(request))
68
+ end
69
+
70
+ # Used by the guard action: #bot_challenge_passed?, and if so also calls the
71
+ # after_session_passed hook. Has side effects (the hook), so app code that just wants
72
+ # to check should use #bot_challenge_passed? instead.
73
+ def _bot_detect_passed_good?(controller)
74
+ return false unless bot_challenge_passed?(controller.request)
75
+
76
+ controller.instance_exec(self, &self.bot_challenge_config.after_session_passed)
77
+ true
69
78
  end
70
79
  end
71
80
  end
@@ -1,3 +1,3 @@
1
1
  module BotChallengePage
2
- VERSION = "1.2.0"
2
+ VERSION = "1.3.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bot_challenge_page
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan Rochkind
@@ -180,7 +180,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
180
180
  - !ruby/object:Gem::Version
181
181
  version: '0'
182
182
  requirements: []
183
- rubygems_version: 4.0.6
183
+ rubygems_version: 3.7.1
184
184
  specification_version: 4
185
185
  summary: Show a bot challenge interstitial for Rails, usually using Cloudflare Turnstile
186
186
  test_files: []