openproject-token 2.0 → 2.1.3
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/open_project/token.rb +32 -6
- data/lib/open_project/token/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d622e466da4e5bf9dab90d1ee1fcfac8757ce2a24fdc19a9c4b4be954081eaa1
|
4
|
+
data.tar.gz: 7ddbec23cf11fb83e1177abf33a942418e009f45567c0015c56fb20b9cea1225
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 87d2219c37f2574e9c7651241e2c49af4f4928b7b84278bc1f92f97c8651142e414a68bdc3e2ce79e57b78df58b82d0c1b6fe6c2719b8889ae1374a5eadd29d3
|
7
|
+
data.tar.gz: 4505d7dca7305c46cd76a7afa3435615f78413d89f60ed28f566c65acb0376fec0bc2adc95c43af09d4f3a73f42656fc6bd6ebbdbd3d08ae728ca31d3932c0d2
|
data/lib/open_project/token.rb
CHANGED
@@ -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
|
-
|
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.include?("version") ? attr["version"] : current_gem_version.to_s
|
200
|
+
version = nil
|
201
|
+
|
202
|
+
if value.present? && value.to_s != "-1"
|
203
|
+
version = Gem::Version.new value
|
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
|
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:
|
4
|
+
version: 2.1.3
|
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-
|
11
|
+
date: 2020-06-30 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.
|
87
|
+
rubygems_version: 3.0.3
|
88
88
|
signing_key:
|
89
89
|
specification_version: 4
|
90
90
|
summary: OpenProject EE token reader
|