queueit_knownuserv3 3.3.0 → 3.6.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.
@@ -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, isStateExtendable, cookieValidityMinute, cookieDomain, secretKey)
18
+ def store(eventId, queueId, fixedCookieValidityMinutes, cookieDomain, redirectType, secretKey)
19
19
  cookieKey = self.class.getCookieKey(eventId)
20
- expirationTime = (Time.now.getutc.tv_sec + (cookieValidityMinute * 60)).to_s
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, isStateExtendable, expirationTime, secretKey)
31
- hashValue = OpenSSL::HMAC.hexdigest('sha256', secretKey, queueId + isStateExtendable + expirationTime)
32
- cookieValue = "QueueId=" + queueId + "&IsCookieExtendable=" + isStateExtendable + "&Expires=" + expirationTime + "&Hash=" + hashValue
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 isCookieValid(cookieNameValueMap, secretKey)
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?("IsCookieExtendable"))
59
+ if (!cookieNameValueMap.key?("EventId"))
55
60
  return false
56
61
  end
57
- if (!cookieNameValueMap.key?("Expires"))
62
+
63
+ if (!cookieNameValueMap.key?("QueueId"))
58
64
  return false
59
65
  end
60
- if (!cookieNameValueMap.key?("Hash"))
66
+
67
+ if (!cookieNameValueMap.key?("RedirectType"))
61
68
  return false
62
69
  end
63
- if (!cookieNameValueMap.key?("QueueId"))
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
- hashValue = OpenSSL::HMAC.hexdigest('sha256', secretKey, cookieNameValueMap["QueueId"] + cookieNameValueMap["IsCookieExtendable"] + cookieNameValueMap["Expires"])
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
- if(Integer(cookieNameValueMap["Expires"]) < Time.now.getutc.tv_sec)
94
+ end
95
+
96
+ if (eventId.upcase != cookieNameValueMap["EventId"].upcase)
71
97
  return false
72
98
  end
73
- return true
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 extendQueueCookie(eventId, cookieValidityMinute, cookieDomain, secretKey)
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,70 @@ module QueueIt
84
123
  end
85
124
 
86
125
  cookieNameValueMap = getCookieNameValueMap(cookieValue)
87
- if (!isCookieValid(cookieNameValueMap, secretKey))
126
+ if (!isCookieValid(secretKey, cookieNameValueMap, eventId, cookieValidityMinutes, true))
88
127
  return
89
128
  end
90
- expirationTime = (Time.now.getutc.tv_sec + (cookieValidityMinute * 60)).to_s
91
- cookieValue = createCookieValue(cookieNameValueMap["QueueId"], cookieNameValueMap["IsCookieExtendable"], expirationTime, secretKey)
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)
96
- cookieKey = cookieKey = self.class.getCookieKey(eventId)
97
- if (@cookieManager.getCookie(cookieKey).nil?)
98
- return StateInfo.new(false, nil, false, 0)
99
- end
100
- cookieNameValueMap = getCookieNameValueMap(@cookieManager.getCookie(cookieKey))
101
- if (!isCookieValid(cookieNameValueMap, secretKey))
102
- return StateInfo.new(false, nil, false,0)
145
+ def getState(eventId, cookieValidityMinutes, secretKey, validateTime)
146
+ begin
147
+ cookieKey = self.class.getCookieKey(eventId)
148
+ if (@cookieManager.getCookie(cookieKey).nil?)
149
+ return StateInfo.new(false, false, nil, nil, nil)
150
+ end
151
+ cookieNameValueMap = getCookieNameValueMap(@cookieManager.getCookie(cookieKey))
152
+ if (!isCookieValid(secretKey, cookieNameValueMap, eventId, cookieValidityMinutes, validateTime))
153
+ return StateInfo.new(true, false, nil, nil, nil)
154
+ end
155
+
156
+ fixedCookieValidityMinutes = nil
157
+ if (cookieNameValueMap.key?("FixedValidityMins"))
158
+ fixedCookieValidityMinutes = cookieNameValueMap["FixedValidityMins"].to_i
159
+ end
160
+
161
+ return StateInfo.new(
162
+ true,
163
+ true,
164
+ cookieNameValueMap["QueueId"],
165
+ fixedCookieValidityMinutes,
166
+ cookieNameValueMap["RedirectType"])
167
+ rescue
168
+ return StateInfo.new(true, false, nil, nil, nil)
103
169
  end
104
- return StateInfo.new(
105
- true,
106
- cookieNameValueMap["QueueId"],
107
- cookieNameValueMap["IsCookieExtendable"] == 'true',
108
- Integer(cookieNameValueMap["Expires"]))
109
170
  end
110
171
  end
111
172
 
112
173
  class StateInfo
174
+ attr_reader :isFound
113
175
  attr_reader :isValid
114
176
  attr_reader :queueId
115
- attr_reader :isStateExtendable
116
- attr_reader :expires # used just for unit tests
177
+ attr_reader :fixedCookieValidityMinutes
178
+ attr_reader :redirectType
117
179
 
118
- def initialize(isValid, queueId, isStateExtendable, expires)
180
+ def initialize(isFound, isValid, queueId, fixedCookieValidityMinutes, redirectType)
181
+ @isFound = isFound
119
182
  @isValid = isValid
120
183
  @queueId = queueId
121
- @isStateExtendable = isStateExtendable
122
- @expires = expires
184
+ @fixedCookieValidityMinutes = fixedCookieValidityMinutes
185
+ @redirectType = redirectType
186
+ end
187
+
188
+ def isStateExtendable
189
+ return @isValid && @fixedCookieValidityMinutes.nil?
123
190
  end
124
191
  end
125
192
  end
@@ -0,0 +1,165 @@
1
+ GNU LESSER GENERAL PUBLIC LICENSE
2
+ Version 3, 29 June 2007
3
+
4
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
5
+ Everyone is permitted to copy and distribute verbatim copies
6
+ of this license document, but changing it is not allowed.
7
+
8
+
9
+ This version of the GNU Lesser General Public License incorporates
10
+ the terms and conditions of version 3 of the GNU General Public
11
+ License, supplemented by the additional permissions listed below.
12
+
13
+ 0. Additional Definitions.
14
+
15
+ As used herein, "this License" refers to version 3 of the GNU Lesser
16
+ General Public License, and the "GNU GPL" refers to version 3 of the GNU
17
+ General Public License.
18
+
19
+ "The Library" refers to a covered work governed by this License,
20
+ other than an Application or a Combined Work as defined below.
21
+
22
+ An "Application" is any work that makes use of an interface provided
23
+ by the Library, but which is not otherwise based on the Library.
24
+ Defining a subclass of a class defined by the Library is deemed a mode
25
+ of using an interface provided by the Library.
26
+
27
+ A "Combined Work" is a work produced by combining or linking an
28
+ Application with the Library. The particular version of the Library
29
+ with which the Combined Work was made is also called the "Linked
30
+ Version".
31
+
32
+ The "Minimal Corresponding Source" for a Combined Work means the
33
+ Corresponding Source for the Combined Work, excluding any source code
34
+ for portions of the Combined Work that, considered in isolation, are
35
+ based on the Application, and not on the Linked Version.
36
+
37
+ The "Corresponding Application Code" for a Combined Work means the
38
+ object code and/or source code for the Application, including any data
39
+ and utility programs needed for reproducing the Combined Work from the
40
+ Application, but excluding the System Libraries of the Combined Work.
41
+
42
+ 1. Exception to Section 3 of the GNU GPL.
43
+
44
+ You may convey a covered work under sections 3 and 4 of this License
45
+ without being bound by section 3 of the GNU GPL.
46
+
47
+ 2. Conveying Modified Versions.
48
+
49
+ If you modify a copy of the Library, and, in your modifications, a
50
+ facility refers to a function or data to be supplied by an Application
51
+ that uses the facility (other than as an argument passed when the
52
+ facility is invoked), then you may convey a copy of the modified
53
+ version:
54
+
55
+ a) under this License, provided that you make a good faith effort to
56
+ ensure that, in the event an Application does not supply the
57
+ function or data, the facility still operates, and performs
58
+ whatever part of its purpose remains meaningful, or
59
+
60
+ b) under the GNU GPL, with none of the additional permissions of
61
+ this License applicable to that copy.
62
+
63
+ 3. Object Code Incorporating Material from Library Header Files.
64
+
65
+ The object code form of an Application may incorporate material from
66
+ a header file that is part of the Library. You may convey such object
67
+ code under terms of your choice, provided that, if the incorporated
68
+ material is not limited to numerical parameters, data structure
69
+ layouts and accessors, or small macros, inline functions and templates
70
+ (ten or fewer lines in length), you do both of the following:
71
+
72
+ a) Give prominent notice with each copy of the object code that the
73
+ Library is used in it and that the Library and its use are
74
+ covered by this License.
75
+
76
+ b) Accompany the object code with a copy of the GNU GPL and this license
77
+ document.
78
+
79
+ 4. Combined Works.
80
+
81
+ You may convey a Combined Work under terms of your choice that,
82
+ taken together, effectively do not restrict modification of the
83
+ portions of the Library contained in the Combined Work and reverse
84
+ engineering for debugging such modifications, if you also do each of
85
+ the following:
86
+
87
+ a) Give prominent notice with each copy of the Combined Work that
88
+ the Library is used in it and that the Library and its use are
89
+ covered by this License.
90
+
91
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
92
+ document.
93
+
94
+ c) For a Combined Work that displays copyright notices during
95
+ execution, include the copyright notice for the Library among
96
+ these notices, as well as a reference directing the user to the
97
+ copies of the GNU GPL and this license document.
98
+
99
+ d) Do one of the following:
100
+
101
+ 0) Convey the Minimal Corresponding Source under the terms of this
102
+ License, and the Corresponding Application Code in a form
103
+ suitable for, and under terms that permit, the user to
104
+ recombine or relink the Application with a modified version of
105
+ the Linked Version to produce a modified Combined Work, in the
106
+ manner specified by section 6 of the GNU GPL for conveying
107
+ Corresponding Source.
108
+
109
+ 1) Use a suitable shared library mechanism for linking with the
110
+ Library. A suitable mechanism is one that (a) uses at run time
111
+ a copy of the Library already present on the user's computer
112
+ system, and (b) will operate properly with a modified version
113
+ of the Library that is interface-compatible with the Linked
114
+ Version.
115
+
116
+ e) Provide Installation Information, but only if you would otherwise
117
+ be required to provide such information under section 6 of the
118
+ GNU GPL, and only to the extent that such information is
119
+ necessary to install and execute a modified version of the
120
+ Combined Work produced by recombining or relinking the
121
+ Application with a modified version of the Linked Version. (If
122
+ you use option 4d0, the Installation Information must accompany
123
+ the Minimal Corresponding Source and Corresponding Application
124
+ Code. If you use option 4d1, you must provide the Installation
125
+ Information in the manner specified by section 6 of the GNU GPL
126
+ for conveying Corresponding Source.)
127
+
128
+ 5. Combined Libraries.
129
+
130
+ You may place library facilities that are a work based on the
131
+ Library side by side in a single library together with other library
132
+ facilities that are not Applications and are not covered by this
133
+ License, and convey such a combined library under terms of your
134
+ choice, if you do both of the following:
135
+
136
+ a) Accompany the combined library with a copy of the same work based
137
+ on the Library, uncombined with any other library facilities,
138
+ conveyed under the terms of this License.
139
+
140
+ b) Give prominent notice with the combined library that part of it
141
+ is a work based on the Library, and explaining where to find the
142
+ accompanying uncombined form of the same work.
143
+
144
+ 6. Revised Versions of the GNU Lesser General Public License.
145
+
146
+ The Free Software Foundation may publish revised and/or new versions
147
+ of the GNU Lesser General Public License from time to time. Such new
148
+ versions will be similar in spirit to the present version, but may
149
+ differ in detail to address new problems or concerns.
150
+
151
+ Each version is given a distinguishing version number. If the
152
+ Library as you received it specifies that a certain numbered version
153
+ of the GNU Lesser General Public License "or any later version"
154
+ applies to it, you have the option of following the terms and
155
+ conditions either of that published version or of any later version
156
+ published by the Free Software Foundation. If the Library as you
157
+ received it does not specify a version number of the GNU Lesser
158
+ General Public License, you may choose any version of the GNU Lesser
159
+ General Public License ever published by the Free Software Foundation.
160
+
161
+ If the Library as you received it specifies that a proxy can decide
162
+ whether future versions of the GNU Lesser General Public License shall
163
+ apply, that proxy's public statement of acceptance of any version is
164
+ permanent authorization for you to choose that version for the
165
+ Library.
@@ -5,7 +5,7 @@ require 'queueit_knownuserv3/user_in_queue_service'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "queueit_knownuserv3"
8
- spec.version = QueueIt::UserInQueueService::SDK_VERSION
8
+ spec.version = QueueIt::UserInQueueService::SDK_VERSION_NO
9
9
  spec.authors = ["Queue-it"]
10
10
  spec.email = ["support@queue-it.com"]
11
11
  spec.licenses = "LGPL-3.0"
@@ -25,7 +25,4 @@ Gem::Specification.new do |spec|
25
25
  spec.bindir = "exe"
26
26
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
27
27
  spec.require_paths = ["lib"]
28
-
29
- spec.add_development_dependency "bundler", "~> 1.11"
30
- spec.add_development_dependency "rake", "~> 10.0"
31
28
  end
metadata CHANGED
@@ -1,43 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: queueit_knownuserv3
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.3.0
4
+ version: 3.6.1
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - Queue-it
8
9
  autorequire:
9
10
  bindir: exe
10
11
  cert_chain: []
11
- date: 2017-10-04 00:00:00.000000000 Z
12
- dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: bundler
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ~>
18
- - !ruby/object:Gem::Version
19
- version: '1.11'
20
- type: :development
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - ~>
25
- - !ruby/object:Gem::Version
26
- version: '1.11'
27
- - !ruby/object:Gem::Dependency
28
- name: rake
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ~>
32
- - !ruby/object:Gem::Version
33
- version: '10.0'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ~>
39
- - !ruby/object:Gem::Version
40
- version: '10.0'
12
+ date: 2020-06-12 00:00:00.000000000 Z
13
+ dependencies: []
41
14
  description:
42
15
  email:
43
16
  - support@queue-it.com
@@ -45,40 +18,48 @@ executables: []
45
18
  extensions: []
46
19
  extra_rdoc_files: []
47
20
  files:
21
+ - .devcontainer/Dockerfile
22
+ - .devcontainer/devcontainer.json
23
+ - .gitignore
24
+ - .vscode/launch.json
48
25
  - Gemfile
49
26
  - Rakefile
50
27
  - bin/console
51
28
  - bin/setup
29
+ - ci-build.yml
52
30
  - lib/queueit_knownuserv3.rb
31
+ - lib/queueit_knownuserv3/connector_diagnostics.rb
53
32
  - lib/queueit_knownuserv3/integration_config_helpers.rb
54
33
  - lib/queueit_knownuserv3/known_user.rb
55
34
  - lib/queueit_knownuserv3/models.rb
56
35
  - lib/queueit_knownuserv3/queue_url_params.rb
57
36
  - lib/queueit_knownuserv3/user_in_queue_service.rb
58
37
  - lib/queueit_knownuserv3/user_in_queue_state_cookie_repository.rb
38
+ - license.txt
59
39
  - queueit_knownuserv3.gemspec
60
40
  homepage: https://www.queue-it.com/
61
41
  licenses:
62
42
  - LGPL-3.0
63
- metadata: {}
64
43
  post_install_message:
65
44
  rdoc_options: []
66
45
  require_paths:
67
46
  - lib
68
47
  required_ruby_version: !ruby/object:Gem::Requirement
48
+ none: false
69
49
  requirements:
70
50
  - - ! '>='
71
51
  - !ruby/object:Gem::Version
72
52
  version: '0'
73
53
  required_rubygems_version: !ruby/object:Gem::Requirement
54
+ none: false
74
55
  requirements:
75
56
  - - ! '>='
76
57
  - !ruby/object:Gem::Version
77
58
  version: '0'
78
59
  requirements: []
79
60
  rubyforge_project:
80
- rubygems_version: 2.6.13
61
+ rubygems_version: 1.8.23.2
81
62
  signing_key:
82
- specification_version: 4
63
+ specification_version: 3
83
64
  summary: Gem for implementing Queue-it KnownUser V3
84
65
  test_files: []