json-jwt 0.3.3 → 0.4.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.
- data/VERSION +1 -1
- data/lib/json/jwk.rb +6 -7
- data/spec/json/jwk_spec.rb +7 -8
- metadata +2 -8
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.4.0
|
data/lib/json/jwk.rb
CHANGED
@@ -41,9 +41,8 @@ module JSON
|
|
41
41
|
when OpenSSL::PKey::RSA
|
42
42
|
{
|
43
43
|
alg: :RSA,
|
44
|
-
|
45
|
-
|
46
|
-
mod: UrlSafeBase64.encode64(public_key.n.to_s(2))
|
44
|
+
e: UrlSafeBase64.encode64(public_key.e.to_s(2)),
|
45
|
+
n: UrlSafeBase64.encode64(public_key.n.to_s(2))
|
47
46
|
}
|
48
47
|
when OpenSSL::PKey::EC
|
49
48
|
{
|
@@ -62,11 +61,11 @@ module JSON
|
|
62
61
|
def decode(jwk)
|
63
62
|
case jwk[:alg].to_s
|
64
63
|
when 'RSA'
|
65
|
-
|
66
|
-
|
64
|
+
e = OpenSSL::BN.new UrlSafeBase64.decode64(jwk[:e]), 2
|
65
|
+
n = OpenSSL::BN.new UrlSafeBase64.decode64(jwk[:n]), 2
|
67
66
|
key = OpenSSL::PKey::RSA.new
|
68
|
-
key.e =
|
69
|
-
key.n =
|
67
|
+
key.e = e
|
68
|
+
key.n = n
|
70
69
|
key
|
71
70
|
when 'EC'
|
72
71
|
raise NotImplementedError.new('Not Implemented Yet')
|
data/spec/json/jwk_spec.rb
CHANGED
@@ -3,11 +3,10 @@ require 'spec_helper'
|
|
3
3
|
describe JSON::JWK do
|
4
4
|
context 'when RSA public key given' do
|
5
5
|
let(:jwk) { JSON::JWK.new public_key }
|
6
|
-
it { jwk.should include :alg, :
|
6
|
+
it { jwk.should include :alg, :e, :n }
|
7
7
|
its(:alg) { jwk[:alg].should == :RSA }
|
8
|
-
its(:
|
9
|
-
its(:
|
10
|
-
its(:mod) { jwk[:mod].should == UrlSafeBase64.encode64(public_key.n.to_s(2)) }
|
8
|
+
its(:e) { jwk[:e].should == UrlSafeBase64.encode64(public_key.e.to_s(2)) }
|
9
|
+
its(:n) { jwk[:n].should == UrlSafeBase64.encode64(public_key.n.to_s(2)) }
|
11
10
|
|
12
11
|
context 'when kid/use options given' do
|
13
12
|
let(:jwk) { JSON::JWK.new public_key, kid: '12345', use: :sig }
|
@@ -68,12 +67,12 @@ describe JSON::JWK do
|
|
68
67
|
subject do
|
69
68
|
JSON::JWK.decode(
|
70
69
|
alg: :RSA,
|
71
|
-
|
72
|
-
|
70
|
+
n: n,
|
71
|
+
e: e
|
73
72
|
)
|
74
73
|
end
|
75
|
-
let(:
|
76
|
-
let(:
|
74
|
+
let(:e) { 'AQAB' }
|
75
|
+
let(:n) { 'AK8ppaAGn6N3jDic2DhDN5mI5mWzvhfL1AFZOS9q2EBM8L5sjZbYiaHeNoKillZGmEF9a9g6Z20bDnoHTuHPsx93HYkZqPumFZ8K9lLCbqKAMWw2Qgk10RgrZ-kblJotTBCeer9-tZSWO-OWFzP4gp8MpSuQOQbwTJwDgEkFIQLUK2YgzWbn1PoW8xcfbVyWhZD880ELGRW6GhRgYAl0DN_EQS8kyUa0CusYCzOOg2W3-7qjYeojyP6jiOEr-eyjC7hcUvTVoTfz84BiZv72KS3i5JS8ZNNuRp5Ce51wjoDDUoNxDLWv6Da6qMaGpKz6NTSNbvhE_KFhpp4wf5yRQD8=' }
|
77
76
|
let(:pem) do
|
78
77
|
if RUBY_VERSION >= '1.9.3'
|
79
78
|
<<-PEM
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: json-jwt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-12-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: json
|
@@ -172,18 +172,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
172
172
|
- - ! '>='
|
173
173
|
- !ruby/object:Gem::Version
|
174
174
|
version: '0'
|
175
|
-
segments:
|
176
|
-
- 0
|
177
|
-
hash: -4331477712692770542
|
178
175
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
179
176
|
none: false
|
180
177
|
requirements:
|
181
178
|
- - ! '>='
|
182
179
|
- !ruby/object:Gem::Version
|
183
180
|
version: '0'
|
184
|
-
segments:
|
185
|
-
- 0
|
186
|
-
hash: -4331477712692770542
|
187
181
|
requirements: []
|
188
182
|
rubyforge_project:
|
189
183
|
rubygems_version: 1.8.24
|