queueit_knownuserv3 3.5.1 → 3.7.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.
@@ -1,185 +1,192 @@
1
- require 'openssl'
2
- require 'base64'
3
- require 'date'
4
-
5
- module QueueIt
6
- class UserInQueueStateCookieRepository
7
- QUEUEIT_DATA_KEY = "QueueITAccepted-SDFrts345E-V3"
8
-
9
- def initialize(cookieManager)
10
- @cookieManager = cookieManager
11
- end
12
-
13
- def cancelQueueCookie(eventId, cookieDomain)
14
- cookieKey = self.class.getCookieKey(eventId)
15
- @cookieManager.setCookie(cookieKey, nil, -1, cookieDomain)
16
- end
17
-
18
- def store(eventId, queueId, fixedCookieValidityMinutes, cookieDomain, redirectType, secretKey)
19
- cookieKey = self.class.getCookieKey(eventId)
20
- cookieValue = createCookieValue(eventId, queueId, Utils.toString(fixedCookieValidityMinutes), redirectType, secretKey)
21
- @cookieManager.setCookie(cookieKey, cookieValue, Time.now + (24*60*60), cookieDomain)
22
- end
23
-
24
- def self.getCookieKey(eventId)
25
- return QUEUEIT_DATA_KEY + '_' + eventId
26
- end
27
-
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
38
- return cookieValue
39
- end
40
-
41
- def getCookieNameValueMap(cookieValue)
42
- result = Hash.new
43
- cookieNameValues = cookieValue.split("&")
44
- cookieNameValues.each do |item|
45
- arr = item.split("=")
46
- if(arr.length == 2)
47
- result[arr[0]] = arr[1]
48
- end
49
- end
50
- return result
51
- end
52
-
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)
58
- begin
59
- if (!cookieNameValueMap.key?("EventId"))
60
- return false
61
- end
62
-
63
- if (!cookieNameValueMap.key?("QueueId"))
64
- return false
65
- end
66
-
67
- if (!cookieNameValueMap.key?("RedirectType"))
68
- return false
69
- end
70
-
71
- if (!cookieNameValueMap.key?("IssueTime"))
72
- return false
73
- end
74
-
75
- if (!cookieNameValueMap.key?("Hash"))
76
- return false
77
- end
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
-
92
- if (hashValue != cookieNameValueMap["Hash"])
93
- return false
94
- end
95
-
96
- if (eventId.upcase != cookieNameValueMap["EventId"].upcase)
97
- return false
98
- end
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
113
- rescue
114
- return false
115
- end
116
- end
117
-
118
- def reissueQueueCookie(eventId, cookieValidityMinutes, cookieDomain, secretKey)
119
- cookieKey = self.class.getCookieKey(eventId)
120
- cookieValue = @cookieManager.getCookie(cookieKey)
121
- if (cookieValue.nil?)
122
- return
123
- end
124
-
125
- cookieNameValueMap = getCookieNameValueMap(cookieValue)
126
- if (!isCookieValid(secretKey, cookieNameValueMap, eventId, cookieValidityMinutes, true))
127
- return
128
- end
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
-
142
- @cookieManager.setCookie(cookieKey, cookieValue, Time.now + (24*60*60), cookieDomain)
143
- end
144
-
145
- def getState(eventId, cookieValidityMinutes, secretKey, validateTime)
146
- cookieKey = cookieKey = self.class.getCookieKey(eventId)
147
- if (@cookieManager.getCookie(cookieKey).nil?)
148
- return StateInfo.new(false, nil, nil, nil)
149
- end
150
- cookieNameValueMap = getCookieNameValueMap(@cookieManager.getCookie(cookieKey))
151
- if (!isCookieValid(secretKey, cookieNameValueMap, eventId, cookieValidityMinutes, validateTime))
152
- return StateInfo.new(false, nil, nil, nil)
153
- end
154
-
155
- fixedCookieValidityMinutes = nil
156
- if (cookieNameValueMap.key?("FixedValidityMins"))
157
- fixedCookieValidityMinutes = cookieNameValueMap["FixedValidityMins"].to_i
158
- end
159
-
160
- return StateInfo.new(
161
- true,
162
- cookieNameValueMap["QueueId"],
163
- fixedCookieValidityMinutes,
164
- cookieNameValueMap["RedirectType"])
165
- end
166
- end
167
-
168
- class StateInfo
169
- attr_reader :isValid
170
- attr_reader :queueId
171
- attr_reader :fixedCookieValidityMinutes
172
- attr_reader :redirectType
173
-
174
- def initialize(isValid, queueId, fixedCookieValidityMinutes, redirectType)
175
- @isValid = isValid
176
- @queueId = queueId
177
- @fixedCookieValidityMinutes = fixedCookieValidityMinutes
178
- @redirectType = redirectType
179
- end
180
-
181
- def isStateExtendable
182
- return @isValid && @fixedCookieValidityMinutes.nil?
183
- end
184
- end
1
+ require 'openssl'
2
+ require 'base64'
3
+ require 'date'
4
+
5
+ module QueueIt
6
+ class UserInQueueStateCookieRepository
7
+ QUEUEIT_DATA_KEY = "QueueITAccepted-SDFrts345E-V3"
8
+
9
+ def initialize(cookieManager)
10
+ @cookieManager = cookieManager
11
+ end
12
+
13
+ def cancelQueueCookie(eventId, cookieDomain, isCookieHttpOnly, isCookieSecure)
14
+ cookieKey = self.class.getCookieKey(eventId)
15
+ @cookieManager.setCookie(cookieKey, nil, -1, cookieDomain, isCookieHttpOnly, isCookieSecure)
16
+ end
17
+
18
+ def store(eventId, queueId, fixedCookieValidityMinutes, cookieDomain, isCookieHttpOnly, isCookieSecure, redirectType, secretKey)
19
+ cookieKey = self.class.getCookieKey(eventId)
20
+ cookieValue = createCookieValue(eventId, queueId, Utils.toString(fixedCookieValidityMinutes), redirectType, secretKey)
21
+ @cookieManager.setCookie(cookieKey, cookieValue, Time.now + (24*60*60), cookieDomain, isCookieHttpOnly, isCookieSecure)
22
+ end
23
+
24
+ def self.getCookieKey(eventId)
25
+ return QUEUEIT_DATA_KEY + '_' + eventId
26
+ end
27
+
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
38
+ return cookieValue
39
+ end
40
+
41
+ def getCookieNameValueMap(cookieValue)
42
+ result = Hash.new
43
+ cookieNameValues = cookieValue.split("&")
44
+ cookieNameValues.each do |item|
45
+ arr = item.split("=")
46
+ if(arr.length == 2)
47
+ result[arr[0]] = arr[1]
48
+ end
49
+ end
50
+ return result
51
+ end
52
+
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)
58
+ begin
59
+ if (!cookieNameValueMap.key?("EventId"))
60
+ return false
61
+ end
62
+
63
+ if (!cookieNameValueMap.key?("QueueId"))
64
+ return false
65
+ end
66
+
67
+ if (!cookieNameValueMap.key?("RedirectType"))
68
+ return false
69
+ end
70
+
71
+ if (!cookieNameValueMap.key?("IssueTime"))
72
+ return false
73
+ end
74
+
75
+ if (!cookieNameValueMap.key?("Hash"))
76
+ return false
77
+ end
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
+
92
+ if (hashValue != cookieNameValueMap["Hash"])
93
+ return false
94
+ end
95
+
96
+ if (eventId.upcase != cookieNameValueMap["EventId"].upcase)
97
+ return false
98
+ end
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
113
+ rescue
114
+ return false
115
+ end
116
+ end
117
+
118
+ def reissueQueueCookie(eventId, cookieValidityMinutes, cookieDomain, isCookieHttpOnly, isCookieSecure, secretKey)
119
+ cookieKey = self.class.getCookieKey(eventId)
120
+ cookieValue = @cookieManager.getCookie(cookieKey)
121
+ if (cookieValue.nil?)
122
+ return
123
+ end
124
+
125
+ cookieNameValueMap = getCookieNameValueMap(cookieValue)
126
+ if (!isCookieValid(secretKey, cookieNameValueMap, eventId, cookieValidityMinutes, true))
127
+ return
128
+ end
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
+
142
+ @cookieManager.setCookie(cookieKey, cookieValue, Time.now + (24*60*60), cookieDomain, isCookieHttpOnly, isCookieSecure)
143
+ end
144
+
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)
169
+ end
170
+ end
171
+ end
172
+
173
+ class StateInfo
174
+ attr_reader :isFound
175
+ attr_reader :isValid
176
+ attr_reader :queueId
177
+ attr_reader :fixedCookieValidityMinutes
178
+ attr_reader :redirectType
179
+
180
+ def initialize(isFound, isValid, queueId, fixedCookieValidityMinutes, redirectType)
181
+ @isFound = isFound
182
+ @isValid = isValid
183
+ @queueId = queueId
184
+ @fixedCookieValidityMinutes = fixedCookieValidityMinutes
185
+ @redirectType = redirectType
186
+ end
187
+
188
+ def isStateExtendable
189
+ return @isValid && @fixedCookieValidityMinutes.nil?
190
+ end
191
+ end
185
192
  end
@@ -1,9 +1,11 @@
1
- require_relative "queueit_knownuserv3/known_user"
2
- require_relative "queueit_knownuserv3/models"
3
- require_relative "queueit_knownuserv3/queue_url_params"
4
- require_relative "queueit_knownuserv3/user_in_queue_state_cookie_repository"
5
- require_relative "queueit_knownuserv3/user_in_queue_service"
6
- require_relative "queueit_knownuserv3/integration_config_helpers"
7
-
8
- module QueueIt
9
- end
1
+ require_relative "queueit_knownuserv3/httpcontext_provider"
2
+ require_relative "queueit_knownuserv3/known_user"
3
+ require_relative "queueit_knownuserv3/models"
4
+ require_relative "queueit_knownuserv3/connector_diagnostics"
5
+ require_relative "queueit_knownuserv3/queue_url_params"
6
+ require_relative "queueit_knownuserv3/user_in_queue_state_cookie_repository"
7
+ require_relative "queueit_knownuserv3/user_in_queue_service"
8
+ require_relative "queueit_knownuserv3/integration_config_helpers"
9
+
10
+ module QueueIt
11
+ end
@@ -1,31 +1,28 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'queueit_knownuserv3/user_in_queue_service'
5
-
6
- Gem::Specification.new do |spec|
7
- spec.name = "queueit_knownuserv3"
8
- spec.version = QueueIt::UserInQueueService::SDK_VERSION
9
- spec.authors = ["Queue-it"]
10
- spec.email = ["support@queue-it.com"]
11
- spec.licenses = "LGPL-3.0"
12
- spec.summary = %q{ Gem for implementing Queue-it KnownUser V3}
13
- spec.homepage = "https://www.queue-it.com/"
14
-
15
- # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
16
- # delete this section to allow pushing this gem to any host.
17
-
18
- # if spec.respond_to?(:metadata)
19
- # spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
20
- # else
21
- # raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
22
- # end
23
-
24
- spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
25
- spec.bindir = "exe"
26
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
27
- spec.require_paths = ["lib"]
28
-
29
- spec.add_development_dependency "bundler", "~> 1.11"
30
- spec.add_development_dependency "rake", "~> 10.0"
31
- end
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'queueit_knownuserv3/user_in_queue_service'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "queueit_knownuserv3"
8
+ spec.version = QueueIt::UserInQueueService::SDK_VERSION_NO
9
+ spec.authors = ["Queue-it"]
10
+ spec.email = ["support@queue-it.com"]
11
+ spec.licenses = "LGPL-3.0"
12
+ spec.summary = %q{ Gem for implementing Queue-it KnownUser V3}
13
+ spec.homepage = "https://www.queue-it.com/"
14
+
15
+ # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
16
+ # delete this section to allow pushing this gem to any host.
17
+
18
+ # if spec.respond_to?(:metadata)
19
+ # spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
20
+ # else
21
+ # raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
22
+ # end
23
+
24
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
25
+ spec.bindir = "exe"
26
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
27
+ spec.require_paths = ["lib"]
28
+ end
metadata CHANGED
@@ -1,43 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: queueit_knownuserv3
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.5.1
4
+ version: 3.7.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: 2018-02-20 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'
11
+ date: 2021-12-07 00:00:00.000000000 Z
12
+ dependencies: []
41
13
  description:
42
14
  email:
43
15
  - support@queue-it.com
@@ -46,10 +18,14 @@ extensions: []
46
18
  extra_rdoc_files: []
47
19
  files:
48
20
  - Gemfile
21
+ - LICENSE
22
+ - README.md
49
23
  - Rakefile
50
24
  - bin/console
51
25
  - bin/setup
52
26
  - lib/queueit_knownuserv3.rb
27
+ - lib/queueit_knownuserv3/connector_diagnostics.rb
28
+ - lib/queueit_knownuserv3/httpcontext_provider.rb
53
29
  - lib/queueit_knownuserv3/integration_config_helpers.rb
54
30
  - lib/queueit_knownuserv3/known_user.rb
55
31
  - lib/queueit_knownuserv3/models.rb
@@ -67,17 +43,16 @@ require_paths:
67
43
  - lib
68
44
  required_ruby_version: !ruby/object:Gem::Requirement
69
45
  requirements:
70
- - - ! '>='
46
+ - - ">="
71
47
  - !ruby/object:Gem::Version
72
48
  version: '0'
73
49
  required_rubygems_version: !ruby/object:Gem::Requirement
74
50
  requirements:
75
- - - ! '>='
51
+ - - ">="
76
52
  - !ruby/object:Gem::Version
77
53
  version: '0'
78
54
  requirements: []
79
- rubyforge_project:
80
- rubygems_version: 2.6.13
55
+ rubygems_version: 3.0.8
81
56
  signing_key:
82
57
  specification_version: 4
83
58
  summary: Gem for implementing Queue-it KnownUser V3