json-jwt 0.7.0.alpha2 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of json-jwt might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/.travis.yml +1 -0
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/lib/json/jwk.rb +18 -14
- data/lib/json/jwk/set.rb +1 -1
- data/spec/json/jwk_spec.rb +20 -7
- data/spec/json/jwt_spec.rb +2 -2
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d95839ba6230af2b99ffc2fa11c6f4243a3a6284
|
4
|
+
data.tar.gz: 7e178d2d41f0ecbd3ec3baeab3b592e803f77c95
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c83c62bbe8bb9ab18c2420be564ce54275ffd90f908951afafd904dacc4bc31b37891b2ddc3d2772daad190fc8614be0f393ce04c94399d8a8d78807c9b481b6
|
7
|
+
data.tar.gz: de9380f86c05ae0c23e37599676a6659ea174ecc2e424533f54fc8107057c42237361aaee1f2ae2e8e078ea3844eb304e5b71d003a0c9ffdb96cd2fb60fcf5e3
|
data/.travis.yml
CHANGED
data/Rakefile
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.7.0
|
1
|
+
0.7.0
|
data/lib/json/jwk.rb
CHANGED
@@ -20,8 +20,8 @@ module JSON
|
|
20
20
|
hex_x = hex[2, data_len/2]
|
21
21
|
hex_y = hex[2+data_len/2, data_len/2]
|
22
22
|
@ecdsa_coodinates = {
|
23
|
-
:
|
24
|
-
:
|
23
|
+
x: [hex_x].pack("H*"),
|
24
|
+
y: [hex_y].pack("H*")
|
25
25
|
}
|
26
26
|
end
|
27
27
|
@ecdsa_coodinates
|
@@ -31,16 +31,16 @@ module JSON
|
|
31
31
|
hash = case public_key
|
32
32
|
when OpenSSL::PKey::RSA
|
33
33
|
{
|
34
|
-
:
|
35
|
-
:
|
36
|
-
:
|
34
|
+
kty: :RSA,
|
35
|
+
e: UrlSafeBase64.encode64(public_key.e.to_s(2)),
|
36
|
+
n: UrlSafeBase64.encode64(public_key.n.to_s(2)),
|
37
37
|
}
|
38
38
|
when OpenSSL::PKey::EC
|
39
39
|
{
|
40
|
-
:
|
41
|
-
:
|
42
|
-
:
|
43
|
-
:
|
40
|
+
kty: :EC,
|
41
|
+
crv: self.class.ecdsa_curve_identifier_for(public_key.group.curve_name),
|
42
|
+
x: UrlSafeBase64.encode64(ecdsa_coodinates(public_key)[:x].to_s),
|
43
|
+
y: UrlSafeBase64.encode64(ecdsa_coodinates(public_key)[:y].to_s),
|
44
44
|
}
|
45
45
|
else
|
46
46
|
raise UnknownAlgorithm.new('Unknown Algorithm')
|
@@ -86,12 +86,16 @@ module JSON
|
|
86
86
|
key.n = n
|
87
87
|
key
|
88
88
|
when 'EC'
|
89
|
-
|
90
|
-
|
91
|
-
|
89
|
+
if RUBY_VERSION >= '2.0.0'
|
90
|
+
key = OpenSSL::PKey::EC.new ecdsa_curve_name_for(jwk[:crv])
|
91
|
+
x, y = [jwk[:x], jwk[:y]].collect do |decoded|
|
92
|
+
OpenSSL::BN.new UrlSafeBase64.decode64(decoded), 2
|
93
|
+
end
|
94
|
+
key.public_key = OpenSSL::PKey::EC::Point.new(key.group).mul(x, y)
|
95
|
+
key
|
96
|
+
else
|
97
|
+
raise UnknownAlgorithm.new('ECDSA JWK Decoding requires Ruby 2.0+')
|
92
98
|
end
|
93
|
-
key.public_key = OpenSSL::PKey::EC::Point.new(key.group).mul(x, y)
|
94
|
-
key
|
95
99
|
else
|
96
100
|
raise UnknownAlgorithm.new('Unknown Algorithm')
|
97
101
|
end
|
data/lib/json/jwk/set.rb
CHANGED
data/spec/json/jwk_spec.rb
CHANGED
@@ -120,13 +120,26 @@ NrqoxoakrPo1NI1u+ET8oWGmnjB/nJFAPwIDAQAB
|
|
120
120
|
end
|
121
121
|
|
122
122
|
context 'when ECDSA' do
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
123
|
+
if RUBY_VERSION >= '2.0.0'
|
124
|
+
it do
|
125
|
+
JSON::JWK.decode(
|
126
|
+
kty: :EC,
|
127
|
+
crv: 'P-256',
|
128
|
+
x: 'MKBCTNIcKUSDii11ySs3526iDZ8AiTo7Tu6KPAqv7D4',
|
129
|
+
y: '4Etl6SRW2YiLUrN5vfvVHuhp7x8PxltmWWlbbM4IFyM'
|
130
|
+
).should be_instance_of OpenSSL::PKey::EC
|
131
|
+
end
|
132
|
+
else
|
133
|
+
it do
|
134
|
+
expect do
|
135
|
+
JSON::JWK.decode(
|
136
|
+
kty: :EC,
|
137
|
+
crv: 'P-256',
|
138
|
+
x: 'MKBCTNIcKUSDii11ySs3526iDZ8AiTo7Tu6KPAqv7D4',
|
139
|
+
y: '4Etl6SRW2YiLUrN5vfvVHuhp7x8PxltmWWlbbM4IFyM'
|
140
|
+
)
|
141
|
+
end.to raise_error JSON::JWK::UnknownAlgorithm
|
142
|
+
end
|
130
143
|
end
|
131
144
|
end
|
132
145
|
|
data/spec/json/jwt_spec.rb
CHANGED
@@ -92,8 +92,8 @@ describe JSON::JWT do
|
|
92
92
|
|
93
93
|
context 'when signed' do
|
94
94
|
it 'should delegate verification to JWS' do
|
95
|
-
jws.
|
96
|
-
JSON::JWS.
|
95
|
+
expect(jws).to receive(:verify)
|
96
|
+
expect(JSON::JWS).to receive(:new).and_return(jws)
|
97
97
|
jwt.verify 'shared_secret'
|
98
98
|
end
|
99
99
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: json-jwt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.0
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- nov matake
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-07-
|
11
|
+
date: 2014-07-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: multi_json
|
@@ -192,9 +192,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
192
192
|
version: '0'
|
193
193
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
194
194
|
requirements:
|
195
|
-
- - "
|
195
|
+
- - ">="
|
196
196
|
- !ruby/object:Gem::Version
|
197
|
-
version:
|
197
|
+
version: '0'
|
198
198
|
requirements: []
|
199
199
|
rubyforge_project:
|
200
200
|
rubygems_version: 2.2.2
|