queueit_knownuserv3 3.4.0 → 3.5.1
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 +8 -8
- data/lib/queueit_knownuserv3/known_user.rb +39 -13
- data/lib/queueit_knownuserv3/models.rb +17 -1
- data/lib/queueit_knownuserv3/queue_url_params.rb +6 -6
- data/lib/queueit_knownuserv3/user_in_queue_service.rb +22 -23
- data/lib/queueit_knownuserv3/user_in_queue_state_cookie_repository.rb +96 -36
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NWIwOWViMTkzYTAzOWQ2OThhYmNiNzM3NTRmOWRlYjYyNjg1YTc4NQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NmI4ZTJkYTM4MzNjYTcyMDU3N2UxMDdjMmMxNjE1MjRiYTlhZjkwNA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZmQxZGEwYTM5ZWE3ZTc5MzdlYzgzZWNhOWZkZjc2M2JiYTMyY2M0YjM1MDg5
|
10
|
+
ZGE1NTAwM2Q0YTcwMGE4ZWNmYmYyOTNiYzY0Mzk1OGQ5OWUwZjNlNjAyYmU3
|
11
|
+
YTRkN2VlNTg3NjI4ZTk3MTExYmI2MThkZmI4MGRjNWEyMTY5MTY=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ODg3OGY5Mjk4M2ZiMzIwOGRkZWZjZTVlMTA0NTViZmU5OTFiNmNkYzc0ZGU4
|
14
|
+
NTQ1ZTU0MzQ5MTlmMjE1YzYwMzEwZGYzOTkzMDdkMjBkOWY1YjIyMDA3OTI5
|
15
|
+
ZTVkZmE4NGIyZTIxODU2MWJmYjQxMWQ3ZDU4OGRmM2YxNmRlYTc=
|
@@ -1,9 +1,11 @@
|
|
1
|
+
require 'cgi'
|
1
2
|
require 'json'
|
2
3
|
|
3
4
|
module QueueIt
|
4
5
|
class KnownUser
|
5
6
|
QUEUEIT_TOKEN_KEY = "queueittoken"
|
6
7
|
QUEUEIT_DEBUG_KEY = "queueitdebug"
|
8
|
+
QUEUEIT_AJAX_HEADER_KEY = "x-queueit-ajaxpageurl"
|
7
9
|
|
8
10
|
@@userInQueueService = nil
|
9
11
|
def self.getUserInQueueService(cookieJar)
|
@@ -15,6 +17,19 @@ module QueueIt
|
|
15
17
|
end
|
16
18
|
private_class_method :getUserInQueueService
|
17
19
|
|
20
|
+
def self.isQueueAjaxCall(request)
|
21
|
+
return request.headers[QUEUEIT_AJAX_HEADER_KEY] != nil
|
22
|
+
end
|
23
|
+
private_class_method :isQueueAjaxCall
|
24
|
+
|
25
|
+
def self.generateTargetUrl(originalTargetUrl, request)
|
26
|
+
unless isQueueAjaxCall(request)
|
27
|
+
return originalTargetUrl
|
28
|
+
end
|
29
|
+
return CGI::unescape(request.headers[QUEUEIT_AJAX_HEADER_KEY])
|
30
|
+
end
|
31
|
+
private_class_method :generateTargetUrl
|
32
|
+
|
18
33
|
def self.convertToInt(value)
|
19
34
|
begin
|
20
35
|
converted = Integer(value)
|
@@ -115,11 +130,15 @@ module QueueIt
|
|
115
130
|
end
|
116
131
|
|
117
132
|
userInQueueService = getUserInQueueService(request.cookie_jar)
|
118
|
-
userInQueueService.validateQueueRequest(targetUrl, queueitToken, queueConfig, customerId, secretKey)
|
133
|
+
result = userInQueueService.validateQueueRequest(targetUrl, queueitToken, queueConfig, customerId, secretKey)
|
134
|
+
result.isAjaxResult = isQueueAjaxCall(request)
|
135
|
+
|
136
|
+
return result
|
119
137
|
end
|
120
138
|
private_class_method :_resolveQueueRequestByLocalConfig
|
121
139
|
|
122
140
|
def self._cancelRequestByLocalConfig(targetUrl, queueitToken, cancelConfig, customerId, secretKey, request, debugEntries)
|
141
|
+
targetUrl = generateTargetUrl(targetUrl, request)
|
123
142
|
isDebug = getIsDebug(queueitToken, secretKey)
|
124
143
|
if(isDebug)
|
125
144
|
debugEntries["TargetUrl"] = targetUrl
|
@@ -158,7 +177,10 @@ module QueueIt
|
|
158
177
|
end
|
159
178
|
|
160
179
|
userInQueueService = getUserInQueueService(request.cookie_jar)
|
161
|
-
userInQueueService.validateCancelRequest(targetUrl, cancelConfig, customerId, secretKey)
|
180
|
+
result = userInQueueService.validateCancelRequest(targetUrl, cancelConfig, customerId, secretKey)
|
181
|
+
result.isAjaxResult = isQueueAjaxCall(request)
|
182
|
+
|
183
|
+
return result
|
162
184
|
end
|
163
185
|
private_class_method :_cancelRequestByLocalConfig
|
164
186
|
|
@@ -183,6 +205,7 @@ module QueueIt
|
|
183
205
|
def self.resolveQueueRequestByLocalConfig(targetUrl, queueitToken, queueConfig, customerId, secretKey, request)
|
184
206
|
debugEntries = Hash.new
|
185
207
|
begin
|
208
|
+
targetUrl = generateTargetUrl(targetUrl, request)
|
186
209
|
return _resolveQueueRequestByLocalConfig(targetUrl, queueitToken, queueConfig, customerId, secretKey, request, debugEntries)
|
187
210
|
ensure
|
188
211
|
setDebugCookie(debugEntries, request.cookie_jar)
|
@@ -223,20 +246,23 @@ module QueueIt
|
|
223
246
|
end
|
224
247
|
|
225
248
|
if(matchedConfig == nil)
|
226
|
-
return RequestValidationResult.new(nil, nil, nil, nil)
|
249
|
+
return RequestValidationResult.new(nil, nil, nil, nil, nil)
|
227
250
|
end
|
228
251
|
|
229
252
|
# unspecified or 'Queue' specified
|
230
253
|
if(!matchedConfig.key?("ActionType") || Utils.isNilOrEmpty(matchedConfig["ActionType"]) || matchedConfig["ActionType"].eql?(ActionTypes::QUEUE))
|
231
|
-
handleQueueAction(currentUrlWithoutQueueITToken, queueitToken, customerIntegration, customerId, secretKey, matchedConfig, request, debugEntries)
|
254
|
+
return handleQueueAction(currentUrlWithoutQueueITToken, queueitToken, customerIntegration, customerId, secretKey, matchedConfig, request, debugEntries)
|
232
255
|
|
233
256
|
elsif(matchedConfig["ActionType"].eql?(ActionTypes::CANCEL))
|
234
|
-
handleCancelAction(currentUrlWithoutQueueITToken, queueitToken, customerIntegration, customerId, secretKey, matchedConfig, request, debugEntries)
|
257
|
+
return handleCancelAction(currentUrlWithoutQueueITToken, queueitToken, customerIntegration, customerId, secretKey, matchedConfig, request, debugEntries)
|
235
258
|
|
236
259
|
# for all unknown types default to 'Ignore'
|
237
260
|
else
|
238
261
|
userInQueueService = getUserInQueueService(request.cookie_jar)
|
239
|
-
userInQueueService.getIgnoreActionResult()
|
262
|
+
result = userInQueueService.getIgnoreActionResult()
|
263
|
+
result.isAjaxResult = isQueueAjaxCall(request)
|
264
|
+
|
265
|
+
return result
|
240
266
|
end
|
241
267
|
|
242
268
|
rescue StandardError => stdErr
|
@@ -263,20 +289,20 @@ module QueueIt
|
|
263
289
|
when "EventTargetUrl"
|
264
290
|
targetUrl = ''
|
265
291
|
else
|
266
|
-
targetUrl = currentUrlWithoutQueueITToken
|
292
|
+
targetUrl = generateTargetUrl(currentUrlWithoutQueueITToken, request)
|
267
293
|
end
|
268
294
|
|
269
295
|
return _resolveQueueRequestByLocalConfig(targetUrl, queueitToken, queueConfig, customerId, secretKey, request, debugEntries)
|
270
296
|
end
|
271
297
|
|
272
298
|
def self.handleCancelAction(currentUrlWithoutQueueITToken, queueitToken, customerIntegration, customerId, secretKey, matchedConfig, request, debugEntries)
|
273
|
-
cancelConfig = CancelEventConfig.new
|
299
|
+
cancelConfig = CancelEventConfig.new
|
274
300
|
cancelConfig.eventId = matchedConfig["EventId"]
|
275
301
|
cancelConfig.queueDomain = matchedConfig["QueueDomain"]
|
276
302
|
cancelConfig.cookieDomain = matchedConfig["CookieDomain"]
|
277
303
|
cancelConfig.version = customerIntegration["Version"]
|
278
304
|
|
279
|
-
return _cancelRequestByLocalConfig(currentUrlWithoutQueueITToken, queueitToken, cancelConfig, customerId, secretKey, request, debugEntries)
|
305
|
+
return _cancelRequestByLocalConfig(currentUrlWithoutQueueITToken, queueitToken, cancelConfig, customerId, secretKey, request, debugEntries)
|
280
306
|
end
|
281
307
|
|
282
308
|
def self.cancelRequestByLocalConfig(targetUrl, queueitToken, cancelConfig, customerId, secretKey, request)
|
@@ -321,9 +347,9 @@ module QueueIt
|
|
321
347
|
@cookies.delete(key)
|
322
348
|
else
|
323
349
|
if(noExpire)
|
324
|
-
@cookies[key] = { :value => value }
|
350
|
+
@cookies[key] = { :value => value, :httponly => false }
|
325
351
|
else
|
326
|
-
@cookies[key] = { :value => value, :expires => expire }
|
352
|
+
@cookies[key] = { :value => value, :expires => expire, :httponly => false }
|
327
353
|
end
|
328
354
|
end
|
329
355
|
else
|
@@ -331,9 +357,9 @@ module QueueIt
|
|
331
357
|
@cookies.delete(key, :domain => domain)
|
332
358
|
else
|
333
359
|
if(noExpire)
|
334
|
-
@cookies[key] = { :value => value, :domain => domain }
|
360
|
+
@cookies[key] = { :value => value, :domain => domain, :httponly => false }
|
335
361
|
else
|
336
|
-
@cookies[key] = { :value => value, :expires => expire, :domain => domain }
|
362
|
+
@cookies[key] = { :value => value, :expires => expire, :domain => domain, :httponly => false }
|
337
363
|
end
|
338
364
|
end
|
339
365
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'cgi'
|
2
|
+
|
1
3
|
module QueueIt
|
2
4
|
class Utils
|
3
5
|
def self.isNilOrEmpty(value)
|
@@ -70,17 +72,31 @@ module QueueIt
|
|
70
72
|
attr_reader :eventId
|
71
73
|
attr_reader :queueId
|
72
74
|
attr_reader :redirectUrl
|
75
|
+
attr_reader :redirectType
|
76
|
+
attr_accessor :isAjaxResult
|
73
77
|
|
74
|
-
def initialize(actionType, eventId, queueId, redirectUrl)
|
78
|
+
def initialize(actionType, eventId, queueId, redirectUrl, redirectType)
|
75
79
|
@actionType = actionType
|
76
80
|
@eventId = eventId
|
77
81
|
@queueId = queueId
|
78
82
|
@redirectUrl = redirectUrl
|
83
|
+
@redirectType = redirectType
|
79
84
|
end
|
80
85
|
|
81
86
|
def doRedirect
|
82
87
|
return !Utils.isNilOrEmpty(@redirectUrl)
|
83
88
|
end
|
89
|
+
|
90
|
+
def getAjaxQueueRedirectHeaderKey
|
91
|
+
return "x-queueit-redirect"
|
92
|
+
end
|
93
|
+
|
94
|
+
def getAjaxRedirectUrl
|
95
|
+
if !Utils.isNilOrEmpty(@redirectUrl)
|
96
|
+
return CGI.escape(@redirectUrl)
|
97
|
+
end
|
98
|
+
return ""
|
99
|
+
end
|
84
100
|
end
|
85
101
|
|
86
102
|
class KnownUserError < StandardError
|
@@ -3,7 +3,7 @@ module QueueIt
|
|
3
3
|
KEY_VALUE_SEPARATOR_GROUP_CHAR = '~';
|
4
4
|
KEY_VALUE_SEPARATOR_CHAR = '_';
|
5
5
|
TIMESTAMP_KEY = "ts"
|
6
|
-
|
6
|
+
COOKIE_VALIDITY_MINUTES_KEY = "cv";
|
7
7
|
EVENT_ID_KEY = "e";
|
8
8
|
EXTENDABLE_COOKIE_KEY = "ce";
|
9
9
|
HASH_KEY = "h";
|
@@ -14,7 +14,7 @@ module QueueIt
|
|
14
14
|
attr_accessor :eventId
|
15
15
|
attr_accessor :hashCode
|
16
16
|
attr_accessor :extendableCookie
|
17
|
-
attr_accessor :
|
17
|
+
attr_accessor :cookieValidityMinutes
|
18
18
|
attr_accessor :queueITToken
|
19
19
|
attr_accessor :queueITTokenWithoutHash
|
20
20
|
attr_accessor :queueId
|
@@ -25,7 +25,7 @@ module QueueIt
|
|
25
25
|
@eventId = ""
|
26
26
|
@hashCode = ""
|
27
27
|
@extendableCookie = false
|
28
|
-
@
|
28
|
+
@cookieValidityMinutes = nil
|
29
29
|
@queueITToken = ""
|
30
30
|
@queueITTokenWithoutHash = ""
|
31
31
|
@queueId = ""
|
@@ -51,11 +51,11 @@ module QueueIt
|
|
51
51
|
rescue
|
52
52
|
result.timeStamp = 0
|
53
53
|
end
|
54
|
-
when
|
54
|
+
when COOKIE_VALIDITY_MINUTES_KEY
|
55
55
|
begin
|
56
|
-
result.
|
56
|
+
result.cookieValidityMinutes = Integer(paramNameValueArr[1])
|
57
57
|
rescue
|
58
|
-
result.
|
58
|
+
result.cookieValidityMinutes = nil
|
59
59
|
end
|
60
60
|
when EVENT_ID_KEY
|
61
61
|
result.eventId = paramNameValueArr[1]
|
@@ -3,25 +3,25 @@ require 'cgi'
|
|
3
3
|
|
4
4
|
module QueueIt
|
5
5
|
class UserInQueueService
|
6
|
-
SDK_VERSION = "3.
|
6
|
+
SDK_VERSION = "3.5.1"
|
7
7
|
|
8
8
|
def initialize(userInQueueStateRepository)
|
9
9
|
@userInQueueStateRepository = userInQueueStateRepository
|
10
10
|
end
|
11
11
|
|
12
12
|
def validateQueueRequest(targetUrl, queueitToken, config, customerId, secretKey)
|
13
|
-
state = @userInQueueStateRepository.getState(config.eventId, secretKey)
|
13
|
+
state = @userInQueueStateRepository.getState(config.eventId, config.cookieValidityMinute, secretKey, true)
|
14
14
|
if (state.isValid)
|
15
|
-
if (state.isStateExtendable && config.extendCookieValidity)
|
15
|
+
if (state.isStateExtendable && config.extendCookieValidity)
|
16
16
|
@userInQueueStateRepository.store(
|
17
17
|
config.eventId,
|
18
18
|
state.queueId,
|
19
|
-
|
20
|
-
config.cookieValidityMinute,
|
19
|
+
nil,
|
21
20
|
!Utils::isNilOrEmpty(config.cookieDomain) ? config.cookieDomain : '',
|
21
|
+
state.redirectType,
|
22
22
|
secretKey)
|
23
23
|
end
|
24
|
-
return RequestValidationResult.new(ActionTypes::QUEUE, config.eventId, state.queueId, nil)
|
24
|
+
return RequestValidationResult.new(ActionTypes::QUEUE, config.eventId, state.queueId, nil, state.redirectType)
|
25
25
|
end
|
26
26
|
|
27
27
|
queueParams = QueueUrlParams::extractQueueParams(queueitToken)
|
@@ -32,22 +32,21 @@ module QueueIt
|
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
|
-
def validateCancelRequest(targetUrl,
|
36
|
-
state = @userInQueueStateRepository.getState(
|
35
|
+
def validateCancelRequest(targetUrl, cancelConfig, customerId, secretKey)
|
36
|
+
state = @userInQueueStateRepository.getState(cancelConfig.eventId, -1, secretKey, false)
|
37
37
|
if (state.isValid)
|
38
|
-
@userInQueueStateRepository.cancelQueueCookie(
|
39
|
-
|
40
|
-
query = getQueryString(customerId, config.eventId, config.version, nil, nil) + ( !Utils::isNilOrEmpty(targetUrl) ? ("&r=" + CGI.escape(targetUrl)) : "" )
|
38
|
+
@userInQueueStateRepository.cancelQueueCookie(cancelConfig.eventId, cancelConfig.cookieDomain)
|
39
|
+
query = getQueryString(customerId, cancelConfig.eventId, cancelConfig.version, nil, nil) + ( !Utils::isNilOrEmpty(targetUrl) ? ("&r=" + CGI.escape(targetUrl)) : "" )
|
41
40
|
|
42
|
-
domainAlias =
|
41
|
+
domainAlias = cancelConfig.queueDomain
|
43
42
|
if (!domainAlias.end_with?("/") )
|
44
43
|
domainAlias = domainAlias + "/"
|
45
44
|
end
|
46
45
|
|
47
|
-
redirectUrl = "https://" + domainAlias + "cancel/" + customerId + "/" +
|
48
|
-
return RequestValidationResult.new(ActionTypes::CANCEL,
|
46
|
+
redirectUrl = "https://" + domainAlias + "cancel/" + customerId + "/" + cancelConfig.eventId + "/?" + query
|
47
|
+
return RequestValidationResult.new(ActionTypes::CANCEL, cancelConfig.eventId, state.queueId, redirectUrl, state.redirectType)
|
49
48
|
else
|
50
|
-
return RequestValidationResult.new(ActionTypes::CANCEL,
|
49
|
+
return RequestValidationResult.new(ActionTypes::CANCEL, cancelConfig.eventId, nil, nil, nil)
|
51
50
|
end
|
52
51
|
end
|
53
52
|
|
@@ -66,11 +65,11 @@ module QueueIt
|
|
66
65
|
@userInQueueStateRepository.store(
|
67
66
|
config.eventId,
|
68
67
|
queueParams.queueId,
|
69
|
-
queueParams.
|
70
|
-
!(queueParams.cookieValidityMinute.nil?) ? queueParams.cookieValidityMinute : config.cookieValidityMinute,
|
68
|
+
queueParams.cookieValidityMinutes,
|
71
69
|
!Utils::isNilOrEmpty(config.cookieDomain) ? config.cookieDomain : '',
|
70
|
+
queueParams.redirectType,
|
72
71
|
secretKey)
|
73
|
-
return RequestValidationResult.new(ActionTypes::QUEUE, config.eventId, queueParams.queueId, nil)
|
72
|
+
return RequestValidationResult.new(ActionTypes::QUEUE, config.eventId, queueParams.queueId, nil, queueParams.redirectType)
|
74
73
|
end
|
75
74
|
|
76
75
|
def getVaidationErrorResult(customerId, targetUrl, config, qParams, errorCode)
|
@@ -83,7 +82,7 @@ module QueueIt
|
|
83
82
|
domainAlias = domainAlias + "/"
|
84
83
|
end
|
85
84
|
redirectUrl = "https://" + domainAlias + "error/" + errorCode + "/?" + query
|
86
|
-
return RequestValidationResult.new(ActionTypes::QUEUE, config.eventId, nil, redirectUrl)
|
85
|
+
return RequestValidationResult.new(ActionTypes::QUEUE, config.eventId, nil, redirectUrl, nil)
|
87
86
|
end
|
88
87
|
|
89
88
|
def getInQueueRedirectResult(targetUrl, config, customerId)
|
@@ -91,7 +90,7 @@ module QueueIt
|
|
91
90
|
"?" + getQueryString(customerId, config.eventId, config.version, config.culture, config.layoutName) +
|
92
91
|
(!Utils::isNilOrEmpty(targetUrl) ? "&t=" +
|
93
92
|
CGI.escape( targetUrl) : "")
|
94
|
-
return RequestValidationResult.new(ActionTypes::QUEUE, config.eventId, nil, redirectUrl)
|
93
|
+
return RequestValidationResult.new(ActionTypes::QUEUE, config.eventId, nil, redirectUrl, nil)
|
95
94
|
end
|
96
95
|
|
97
96
|
def getQueryString(customerId, eventId, configVersion, culture, layoutName)
|
@@ -109,12 +108,12 @@ module QueueIt
|
|
109
108
|
return queryStringList.join("&")
|
110
109
|
end
|
111
110
|
|
112
|
-
def extendQueueCookie(eventId,
|
113
|
-
@userInQueueStateRepository.
|
111
|
+
def extendQueueCookie(eventId, cookieValidityMinutes, cookieDomain, secretKey)
|
112
|
+
@userInQueueStateRepository.reissueQueueCookie(eventId, cookieValidityMinutes, cookieDomain, secretKey)
|
114
113
|
end
|
115
114
|
|
116
115
|
def getIgnoreActionResult()
|
117
|
-
return RequestValidationResult.new(ActionTypes::IGNORE, nil, nil, nil)
|
116
|
+
return RequestValidationResult.new(ActionTypes::IGNORE, nil, nil, nil, nil)
|
118
117
|
end
|
119
118
|
end
|
120
119
|
end
|
@@ -12,14 +12,12 @@ module QueueIt
|
|
12
12
|
|
13
13
|
def cancelQueueCookie(eventId, cookieDomain)
|
14
14
|
cookieKey = self.class.getCookieKey(eventId)
|
15
|
-
@cookieManager.setCookie(cookieKey, nil, -1, cookieDomain)
|
15
|
+
@cookieManager.setCookie(cookieKey, nil, -1, cookieDomain)
|
16
16
|
end
|
17
17
|
|
18
|
-
def store(eventId, queueId,
|
18
|
+
def store(eventId, queueId, fixedCookieValidityMinutes, cookieDomain, redirectType, secretKey)
|
19
19
|
cookieKey = self.class.getCookieKey(eventId)
|
20
|
-
|
21
|
-
isStateExtendableString = (isStateExtendable) ? 'true' : 'false'
|
22
|
-
cookieValue = createCookieValue(queueId, isStateExtendableString, expirationTime, secretKey)
|
20
|
+
cookieValue = createCookieValue(eventId, queueId, Utils.toString(fixedCookieValidityMinutes), redirectType, secretKey)
|
23
21
|
@cookieManager.setCookie(cookieKey, cookieValue, Time.now + (24*60*60), cookieDomain)
|
24
22
|
end
|
25
23
|
|
@@ -27,19 +25,22 @@ module QueueIt
|
|
27
25
|
return QUEUEIT_DATA_KEY + '_' + eventId
|
28
26
|
end
|
29
27
|
|
30
|
-
def createCookieValue(queueId,
|
31
|
-
|
32
|
-
|
28
|
+
def createCookieValue(eventId, queueId, fixedCookieValidityMinutes, redirectType, secretKey)
|
29
|
+
issueTime = Time.now.getutc.tv_sec.to_s
|
30
|
+
hashValue = generateHash(eventId, queueId, fixedCookieValidityMinutes, redirectType, issueTime, secretKey)
|
31
|
+
|
32
|
+
fixedCookieValidityMinutesPart = ""
|
33
|
+
if(!Utils.isNilOrEmpty(fixedCookieValidityMinutes))
|
34
|
+
fixedCookieValidityMinutesPart = "&FixedValidityMins=" + fixedCookieValidityMinutes
|
35
|
+
end
|
36
|
+
|
37
|
+
cookieValue = "EventId=" + eventId + "&QueueId=" + queueId + fixedCookieValidityMinutesPart + "&RedirectType=" + redirectType + "&IssueTime=" + issueTime + "&Hash=" + hashValue
|
33
38
|
return cookieValue
|
34
39
|
end
|
35
40
|
|
36
41
|
def getCookieNameValueMap(cookieValue)
|
37
42
|
result = Hash.new
|
38
43
|
cookieNameValues = cookieValue.split("&")
|
39
|
-
if (cookieNameValues.length != 4)
|
40
|
-
return result
|
41
|
-
end
|
42
|
-
|
43
44
|
cookieNameValues.each do |item|
|
44
45
|
arr = item.split("=")
|
45
46
|
if(arr.length == 2)
|
@@ -49,34 +50,72 @@ module QueueIt
|
|
49
50
|
return result
|
50
51
|
end
|
51
52
|
|
52
|
-
def
|
53
|
+
def generateHash(eventId, queueId, fixedCookieValidityMinutes, redirectType, issueTime, secretKey)
|
54
|
+
OpenSSL::HMAC.hexdigest('sha256', secretKey, eventId + queueId + fixedCookieValidityMinutes + redirectType + issueTime)
|
55
|
+
end
|
56
|
+
|
57
|
+
def isCookieValid(secretKey, cookieNameValueMap, eventId, cookieValidityMinutes, validateTime)
|
53
58
|
begin
|
54
|
-
if (!cookieNameValueMap.key?("
|
59
|
+
if (!cookieNameValueMap.key?("EventId"))
|
55
60
|
return false
|
56
61
|
end
|
57
|
-
|
62
|
+
|
63
|
+
if (!cookieNameValueMap.key?("QueueId"))
|
58
64
|
return false
|
59
65
|
end
|
60
|
-
|
66
|
+
|
67
|
+
if (!cookieNameValueMap.key?("RedirectType"))
|
61
68
|
return false
|
62
69
|
end
|
63
|
-
|
70
|
+
|
71
|
+
if (!cookieNameValueMap.key?("IssueTime"))
|
72
|
+
return false
|
73
|
+
end
|
74
|
+
|
75
|
+
if (!cookieNameValueMap.key?("Hash"))
|
64
76
|
return false
|
65
77
|
end
|
66
|
-
|
78
|
+
|
79
|
+
fixedCookieValidityMinutes = ""
|
80
|
+
if (cookieNameValueMap.key?("FixedValidityMins"))
|
81
|
+
fixedCookieValidityMinutes = cookieNameValueMap["FixedValidityMins"]
|
82
|
+
end
|
83
|
+
|
84
|
+
hashValue = generateHash(
|
85
|
+
cookieNameValueMap["EventId"],
|
86
|
+
cookieNameValueMap["QueueId"],
|
87
|
+
fixedCookieValidityMinutes,
|
88
|
+
cookieNameValueMap["RedirectType"],
|
89
|
+
cookieNameValueMap["IssueTime"],
|
90
|
+
secretKey)
|
91
|
+
|
67
92
|
if (hashValue != cookieNameValueMap["Hash"])
|
68
93
|
return false
|
69
|
-
end
|
70
|
-
|
94
|
+
end
|
95
|
+
|
96
|
+
if (eventId.upcase != cookieNameValueMap["EventId"].upcase)
|
71
97
|
return false
|
72
98
|
end
|
73
|
-
|
99
|
+
|
100
|
+
if(validateTime)
|
101
|
+
validity = cookieValidityMinutes
|
102
|
+
if(!Utils.isNilOrEmpty(fixedCookieValidityMinutes))
|
103
|
+
validity = fixedCookieValidityMinutes.to_i
|
104
|
+
end
|
105
|
+
|
106
|
+
expirationTime = cookieNameValueMap["IssueTime"].to_i + (validity*60)
|
107
|
+
if(expirationTime < Time.now.getutc.tv_sec)
|
108
|
+
return false
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
return true
|
74
113
|
rescue
|
75
114
|
return false
|
76
115
|
end
|
77
116
|
end
|
78
117
|
|
79
|
-
def
|
118
|
+
def reissueQueueCookie(eventId, cookieValidityMinutes, cookieDomain, secretKey)
|
80
119
|
cookieKey = self.class.getCookieKey(eventId)
|
81
120
|
cookieValue = @cookieManager.getCookie(cookieKey)
|
82
121
|
if (cookieValue.nil?)
|
@@ -84,42 +123,63 @@ module QueueIt
|
|
84
123
|
end
|
85
124
|
|
86
125
|
cookieNameValueMap = getCookieNameValueMap(cookieValue)
|
87
|
-
if (!isCookieValid(cookieNameValueMap,
|
126
|
+
if (!isCookieValid(secretKey, cookieNameValueMap, eventId, cookieValidityMinutes, true))
|
88
127
|
return
|
89
128
|
end
|
90
|
-
|
91
|
-
|
129
|
+
|
130
|
+
fixedCookieValidityMinutes = ""
|
131
|
+
if (cookieNameValueMap.key?("FixedValidityMins"))
|
132
|
+
fixedCookieValidityMinutes = cookieNameValueMap["FixedValidityMins"]
|
133
|
+
end
|
134
|
+
|
135
|
+
cookieValue = createCookieValue(
|
136
|
+
eventId,
|
137
|
+
cookieNameValueMap["QueueId"],
|
138
|
+
fixedCookieValidityMinutes,
|
139
|
+
cookieNameValueMap["RedirectType"],
|
140
|
+
secretKey)
|
141
|
+
|
92
142
|
@cookieManager.setCookie(cookieKey, cookieValue, Time.now + (24*60*60), cookieDomain)
|
93
143
|
end
|
94
144
|
|
95
|
-
def getState(eventId, secretKey)
|
145
|
+
def getState(eventId, cookieValidityMinutes, secretKey, validateTime)
|
96
146
|
cookieKey = cookieKey = self.class.getCookieKey(eventId)
|
97
147
|
if (@cookieManager.getCookie(cookieKey).nil?)
|
98
|
-
return StateInfo.new(false, nil,
|
148
|
+
return StateInfo.new(false, nil, nil, nil)
|
99
149
|
end
|
100
150
|
cookieNameValueMap = getCookieNameValueMap(@cookieManager.getCookie(cookieKey))
|
101
|
-
if (!isCookieValid(cookieNameValueMap,
|
102
|
-
return StateInfo.new(false, nil,
|
151
|
+
if (!isCookieValid(secretKey, cookieNameValueMap, eventId, cookieValidityMinutes, validateTime))
|
152
|
+
return StateInfo.new(false, nil, nil, nil)
|
103
153
|
end
|
154
|
+
|
155
|
+
fixedCookieValidityMinutes = nil
|
156
|
+
if (cookieNameValueMap.key?("FixedValidityMins"))
|
157
|
+
fixedCookieValidityMinutes = cookieNameValueMap["FixedValidityMins"].to_i
|
158
|
+
end
|
159
|
+
|
104
160
|
return StateInfo.new(
|
105
161
|
true,
|
106
162
|
cookieNameValueMap["QueueId"],
|
107
|
-
|
108
|
-
|
163
|
+
fixedCookieValidityMinutes,
|
164
|
+
cookieNameValueMap["RedirectType"])
|
109
165
|
end
|
110
166
|
end
|
111
167
|
|
112
168
|
class StateInfo
|
113
169
|
attr_reader :isValid
|
114
170
|
attr_reader :queueId
|
115
|
-
attr_reader :
|
116
|
-
attr_reader :
|
171
|
+
attr_reader :fixedCookieValidityMinutes
|
172
|
+
attr_reader :redirectType
|
117
173
|
|
118
|
-
def initialize(isValid, queueId,
|
174
|
+
def initialize(isValid, queueId, fixedCookieValidityMinutes, redirectType)
|
119
175
|
@isValid = isValid
|
120
176
|
@queueId = queueId
|
121
|
-
@
|
122
|
-
@
|
177
|
+
@fixedCookieValidityMinutes = fixedCookieValidityMinutes
|
178
|
+
@redirectType = redirectType
|
179
|
+
end
|
180
|
+
|
181
|
+
def isStateExtendable
|
182
|
+
return @isValid && @fixedCookieValidityMinutes.nil?
|
123
183
|
end
|
124
184
|
end
|
125
185
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: queueit_knownuserv3
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Queue-it
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-02-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|