openproject-token 2.0 → 2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5da90cc05359f099b94484c379973b4c4464b8f9ef7f6d20bdefba2b4fc61537
4
- data.tar.gz: 5f87461bbf02ecf0d8c5663b4dba13ea9c511dbd807d8c3e15e4adfe5c040f57
3
+ metadata.gz: ead9b5f2d9c6a6397a00c9b78b808ffa9c181787f35103cbfca3167932f01f8f
4
+ data.tar.gz: 5fd6f7a10fbaaa88c74e843dd90c8aa85cd190e44e73f3338f84d571d5bd2794
5
5
  SHA512:
6
- metadata.gz: dd82c0f1815535f7e568d969a1c4e469beaf4d5470014c59496c12e2cd82edf0b9c6e6d9267cfa4b97ef9b6408a737f41fb1d8ae3cdb70c7353ae29f4e7cb940
7
- data.tar.gz: ec350f3838ec36b45fb6d0671bac492abd0bf7b5975ced83f2c430b6148274e34d93907525830aa4c5dc44fc2e2182f4092d7bc818d11bfdcd906a77a5411eda
6
+ metadata.gz: 24cda16d34060e6c6a0b76a36243c1c83caff021adc0fe768ed5f4093639de923597a9f46adf48cac7ef295cd0e7b2a5bb88a2cc03ea74eb06c1419c98f73921
7
+ data.tar.gz: b5373b041a70d3402881fa4b4fbcf1cecfb36d996c67d61373daf004e88e04a528bfbfa9e909dce749fbd19578d9ad052267999f59122ced451588543a5c0643
@@ -155,13 +155,8 @@ module OpenProject
155
155
 
156
156
  def load_attributes(attributes)
157
157
  attributes = Hash[attributes.map { |k, v| [k.to_s, v] }]
158
- version = attributes["version"].then { |v| v && Gem::Version.new(v) } || current_gem_version
159
158
 
160
- if version > current_gem_version
161
- raise ArgumentError, "Version is too new"
162
- end
163
-
164
- @version = version.to_s
159
+ @version = read_version attributes
165
160
  @subscriber = attributes["subscriber"]
166
161
  @mail = attributes["mail"]
167
162
  @company = attributes["company"]
@@ -184,6 +179,37 @@ module OpenProject
184
179
  end
185
180
  end
186
181
 
182
+ ##
183
+ # Reads the version from the given attributes hash.
184
+ # Besides the usual values it allows for a special value `-1`.
185
+ # This is then results in the version being `nil` specifically rather than
186
+ # the current gem version by default.
187
+ #
188
+ # This way the generated token will get what ever version the importing party
189
+ # has. This is important due to a bug in openproject-token 1.x where any version
190
+ # other than `nil` (or the integer literal 1) results in a "Version is too new" error.
191
+ # This affects all OpenProject installations with a version older than 10.6
192
+ # which will run into internal server errors trying to activate their Enterprise
193
+ # tokens due to this.
194
+ #
195
+ # Generating tokens with version `-1` prevents that.
196
+ #
197
+ # @param attr [Hash] Parsed token attributes.
198
+ def read_version(attr)
199
+ value = attr["version"]
200
+ version = nil
201
+
202
+ if value.to_s != "-1"
203
+ version = value.then { |v| v && Gem::Version.new(v) } || current_gem_version
204
+
205
+ if version > current_gem_version
206
+ raise ArgumentError, "Version is too new"
207
+ end
208
+ end
209
+
210
+ version
211
+ end
212
+
187
213
  def date_attribute_keys
188
214
  %w(starts_at issued_at expires_at notify_admins_at notify_users_at block_changes_at)
189
215
  end
@@ -1,5 +1,5 @@
1
1
  module OpenProject
2
2
  class Token
3
- VERSION = "2.0"
3
+ VERSION = "2.1"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openproject-token
3
3
  version: !ruby/object:Gem::Version
4
- version: '2.0'
4
+ version: '2.1'
5
5
  platform: ruby
6
6
  authors:
7
7
  - OpenProject GmbH
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-05-15 00:00:00.000000000 Z
11
+ date: 2020-06-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel
@@ -84,7 +84,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
84
84
  - !ruby/object:Gem::Version
85
85
  version: '0'
86
86
  requirements: []
87
- rubygems_version: 3.0.1
87
+ rubygems_version: 3.0.3
88
88
  signing_key:
89
89
  specification_version: 4
90
90
  summary: OpenProject EE token reader