authbox 0.0.5 → 0.0.6
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 +4 -4
- data/lib/authbox.rb +21 -23
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 043a3f024ab2ffbee3924fbb1db65f0355a37b71
|
4
|
+
data.tar.gz: c05d9d06d4a9c94b5629a529225e8c3f22f220cb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 50a26b11ba2b16dcd23ff55018c47be35e1662fc5cccfbf4b0b9bb997e74076e753dbb84665fd569e9f47abfb0157124aa43a1b86791f83a6752bcb2fe843584
|
7
|
+
data.tar.gz: 9004ce71a310cbc65ba6b904451c05db4e712eb127228e6eb3e39819f02348e2f2b80cb539ffd48ca37f395a29ea15818ee623c2348b4adea6589186f54923dd
|
data/lib/authbox.rb
CHANGED
@@ -55,31 +55,25 @@ module Authbox
|
|
55
55
|
# will be logged. See the documentation for what information
|
56
56
|
# you can pass here in the action hash.
|
57
57
|
def authbox_log(action={})
|
58
|
-
if not authbox_ensure_one_request()
|
59
|
-
return
|
58
|
+
if not authbox_ensure_one_request(:log)
|
59
|
+
return
|
60
60
|
end
|
61
61
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
def authbox_check(action={})
|
66
|
-
if not authbox_ensure_one_request()
|
67
|
-
return @authbox_verdict
|
62
|
+
if not @authbox_verdict.blank? and @authbox_verdict['type'] != 'ALLOW'
|
63
|
+
return
|
68
64
|
end
|
69
65
|
|
70
|
-
|
66
|
+
|
67
|
+
return authbox_request('/action_log', action, true)
|
71
68
|
end
|
72
69
|
|
73
|
-
def
|
74
|
-
if not authbox_ensure_one_request()
|
70
|
+
def authbox_check(action={})
|
71
|
+
if not authbox_ensure_one_request(:check)
|
75
72
|
return @authbox_verdict
|
76
73
|
end
|
77
74
|
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
def authbox_end(action={})
|
82
|
-
return authbox_request('/action_end', action, false)
|
75
|
+
@authbox_check_action = action
|
76
|
+
return authbox_request('/action_check', action, false)
|
83
77
|
end
|
84
78
|
|
85
79
|
##
|
@@ -143,13 +137,13 @@ module Authbox
|
|
143
137
|
return Rails.configuration.authbox[:endpoint] || 'https://api.authbox.io/api'
|
144
138
|
end
|
145
139
|
|
146
|
-
def authbox_ensure_one_request
|
147
|
-
if @
|
140
|
+
def authbox_ensure_one_request(type)
|
141
|
+
if @authbox_fired[type]
|
148
142
|
authbox_warn_log { 'authbox_log() already called' }
|
149
143
|
return false
|
150
144
|
end
|
151
145
|
|
152
|
-
@
|
146
|
+
@authbox_fired[type] = true
|
153
147
|
return true
|
154
148
|
end
|
155
149
|
|
@@ -217,7 +211,7 @@ module Authbox
|
|
217
211
|
begin
|
218
212
|
parsed_response = JSON.parse(response.body)
|
219
213
|
if not parsed_response.has_key? 'type'
|
220
|
-
@authbox_verdict = {'type' => 'ALLOW', 'info' => 'No verdict
|
214
|
+
@authbox_verdict = {'type' => 'ALLOW', 'info' => 'No verdict returned'}
|
221
215
|
return @authbox_verdict
|
222
216
|
end
|
223
217
|
rescue => e
|
@@ -238,13 +232,17 @@ module Authbox
|
|
238
232
|
end
|
239
233
|
|
240
234
|
def authbox_before
|
241
|
-
@
|
235
|
+
@authbox_fired = {
|
236
|
+
:check => false,
|
237
|
+
:log => false
|
238
|
+
}
|
239
|
+
@authbox_check_action = {}
|
242
240
|
@authbox_insert_pixel = rand() < 0.01
|
243
241
|
end
|
244
242
|
|
245
243
|
def authbox_after
|
246
|
-
if not @
|
247
|
-
authbox_log
|
244
|
+
if not @authbox_fired[:log]
|
245
|
+
authbox_log @authbox_check_action
|
248
246
|
|
249
247
|
if @authbox_insert_pixel and Rails.configuration.authbox.fetch(:enable_tracking_pixel, true)
|
250
248
|
endpoint = authbox_get_endpoint()
|