bot_challenge_page 1.1.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: 0f487a01c979d017a65f2ef03c460ecd54eab49047fefd344d31f0b17f7d43fa
4
- data.tar.gz: 4e1ff3d6d6fb127a99fdb8d59a2251f5473138f1b9dcd361762f6700b96586f8
3
+ metadata.gz: 84489b3222b7f78c52f1d952362c0105c3bbd0973311e7847246ae2182b42eac
4
+ data.tar.gz: 99bfc469263b9bc6101733e864273e7a956ececa7c66f41ee52f163257518be3
5
5
  SHA512:
6
- metadata.gz: 05e2489f513ef948b8d0a1ec2446d722a5277ac8e88c78676efbd3ebc5befa564d981e98e288786de9b237035e4213d48250b7ef6288f687ee6127b67538824b
7
- data.tar.gz: db452f92074ac849d6e568bba787e684951c4977d0176b359179c974fa51b3d464c0b9494212345183638f6e669a3a0ea577eb0446ff954b14ced5bcaca93aff
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.1.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.1.0
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan Rochkind
@@ -117,16 +117,22 @@ dependencies:
117
117
  name: http
118
118
  requirement: !ruby/object:Gem::Requirement
119
119
  requirements:
120
- - - "~>"
120
+ - - ">="
121
121
  - !ruby/object:Gem::Version
122
122
  version: '5.2'
123
+ - - "<"
124
+ - !ruby/object:Gem::Version
125
+ version: '7'
123
126
  type: :runtime
124
127
  prerelease: false
125
128
  version_requirements: !ruby/object:Gem::Requirement
126
129
  requirements:
127
- - - "~>"
130
+ - - ">="
128
131
  - !ruby/object:Gem::Version
129
132
  version: '5.2'
133
+ - - "<"
134
+ - !ruby/object:Gem::Version
135
+ version: '7'
130
136
  email:
131
137
  - jonathan@dnil.net
132
138
  executables: []