openproject-token 8.1.0 → 8.3.0
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/extractor.rb +37 -3
- data/lib/open_project/token/plans.rb +1 -0
- data/lib/open_project/token/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b9a6cd09cc78e050108eda243bc4abac221821625040cc36bb33e98d38ca27f2
|
|
4
|
+
data.tar.gz: 0eaa921bc56a56aebce2dd9aaa9f3879f52d7e7f8789261636bcde64802dd8ac
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 76b84b185be0f93f9ff001f55a9f7c5415269249916c1028d59c8f4e9a5f707dbff9c4ee8c3812e4d65be686904d6dfad4bfd64a1c786c6f53e376d2bed4127b
|
|
7
|
+
data.tar.gz: 15ee68a90091c9ae799a3082f292bfb7e3445d4084fe8dad495084fffaf87aac3e63ccbac5b7128b4c6dd2b61edec46cfa51d0572d2e7d4cd607543c2451b199
|
|
@@ -6,6 +6,7 @@ module OpenProject
|
|
|
6
6
|
class Error < StandardError; end
|
|
7
7
|
class KeyError < Error; end
|
|
8
8
|
class DecryptionError < Error; end
|
|
9
|
+
class SignatureError < Error; end
|
|
9
10
|
|
|
10
11
|
attr_accessor :key
|
|
11
12
|
|
|
@@ -13,7 +14,7 @@ module OpenProject
|
|
|
13
14
|
@key = key
|
|
14
15
|
end
|
|
15
16
|
|
|
16
|
-
def read(data)
|
|
17
|
+
def read(data)
|
|
17
18
|
unless key.public?
|
|
18
19
|
raise KeyError, "Provided key is not a public key."
|
|
19
20
|
end
|
|
@@ -21,11 +22,44 @@ module OpenProject
|
|
|
21
22
|
json_data = Base64.decode64(data.chomp)
|
|
22
23
|
|
|
23
24
|
begin
|
|
24
|
-
|
|
25
|
+
container = JSON.parse(json_data)
|
|
25
26
|
rescue JSON::ParserError
|
|
26
27
|
raise DecryptionError, "Encryption data is invalid JSON."
|
|
27
28
|
end
|
|
28
29
|
|
|
30
|
+
if container["payload"].nil?
|
|
31
|
+
decrypt_encryption_data(container)
|
|
32
|
+
else
|
|
33
|
+
decrypt_signed_format(container)
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
private
|
|
38
|
+
|
|
39
|
+
def decrypt_signed_format(container)
|
|
40
|
+
payload_data = Base64.decode64(container["payload"])
|
|
41
|
+
signature = Base64.decode64(container["signature"])
|
|
42
|
+
|
|
43
|
+
# Verify signature of the entire payload
|
|
44
|
+
begin
|
|
45
|
+
unless key.verify(OpenSSL::Digest.new("SHA256"), signature, payload_data)
|
|
46
|
+
raise SignatureError, "Signature verification failed."
|
|
47
|
+
end
|
|
48
|
+
rescue OpenSSL::PKey::RSAError => e
|
|
49
|
+
raise SignatureError, "Signature verification failed: #{e.message}"
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
# Parse the verified payload
|
|
53
|
+
begin
|
|
54
|
+
encryption_data = JSON.parse(payload_data)
|
|
55
|
+
rescue JSON::ParserError
|
|
56
|
+
raise DecryptionError, "Payload data is invalid JSON."
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
decrypt_encryption_data(encryption_data)
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def decrypt_encryption_data(encryption_data) # rubocop:disable Metrics/AbcSize
|
|
29
63
|
unless %w(data key iv).all? { |key| encryption_data[key] }
|
|
30
64
|
raise DecryptionError, "Required field missing from encryption data."
|
|
31
65
|
end
|
|
@@ -36,7 +70,7 @@ module OpenProject
|
|
|
36
70
|
|
|
37
71
|
begin
|
|
38
72
|
# Decrypt the AES key using asymmetric RSA encryption.
|
|
39
|
-
aes_key =
|
|
73
|
+
aes_key = key.public_decrypt(encrypted_key)
|
|
40
74
|
rescue OpenSSL::PKey::RSAError
|
|
41
75
|
raise DecryptionError, "AES encryption key could not be decrypted."
|
|
42
76
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: openproject-token
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 8.
|
|
4
|
+
version: 8.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- OpenProject GmbH
|
|
@@ -48,7 +48,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
48
48
|
requirements:
|
|
49
49
|
- - ">="
|
|
50
50
|
- !ruby/object:Gem::Version
|
|
51
|
-
version: 3.4.
|
|
51
|
+
version: 3.4.7
|
|
52
52
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
53
53
|
requirements:
|
|
54
54
|
- - ">="
|