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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a279683e6d96616536c1f63ccb1f1d51a37398f2
4
- data.tar.gz: 5a3cbe00175853947bb1876b546c9061a465547e
3
+ metadata.gz: d95839ba6230af2b99ffc2fa11c6f4243a3a6284
4
+ data.tar.gz: 7e178d2d41f0ecbd3ec3baeab3b592e803f77c95
5
5
  SHA512:
6
- metadata.gz: e94d5cd60ec9e4927a02e1aaefe7ede13322848111bab88ba44356e9131f435334d2cf12cdb062de025e68f7455ecc450a34e088e848cc1746730497e4bbe7ec
7
- data.tar.gz: d143c8421971af2160ace61ea9a676864344025ebf950d14376a8d499250e3b9e0a268004a9945ebbc5a55230c07acbc32dc94871cd2122301589176edcd4fcc
6
+ metadata.gz: c83c62bbe8bb9ab18c2420be564ce54275ffd90f908951afafd904dacc4bc31b37891b2ddc3d2772daad190fc8614be0f393ce04c94399d8a8d78807c9b481b6
7
+ data.tar.gz: de9380f86c05ae0c23e37599676a6659ea174ecc2e424533f54fc8107057c42237361aaee1f2ae2e8e078ea3844eb304e5b71d003a0c9ffdb96cd2fb60fcf5e3
data/.travis.yml CHANGED
@@ -1,6 +1,7 @@
1
1
  rvm:
2
2
  - 1.9.3
3
3
  - 2.0.0
4
+ - 2.1.2
4
5
 
5
6
  before_install:
6
7
  - git submodule update --init --recursive
data/Rakefile CHANGED
@@ -16,4 +16,4 @@ task :spec do
16
16
  Rake::Task[:'coverage:report'].invoke unless ENV['TRAVIS_RUBY_VERSION']
17
17
  end
18
18
 
19
- task :default => :spec
19
+ task default: :spec
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.7.0.alpha2
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
- :x => [hex_x].pack("H*"),
24
- :y => [hex_y].pack("H*")
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
- :kty => :RSA,
35
- :e => UrlSafeBase64.encode64(public_key.e.to_s(2)),
36
- :n => UrlSafeBase64.encode64(public_key.n.to_s(2)),
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
- :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),
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
- key = OpenSSL::PKey::EC.new ecdsa_curve_name_for(jwk[:crv])
90
- x, y = [jwk[:x], jwk[:y]].collect do |decoded|
91
- OpenSSL::BN.new UrlSafeBase64.decode64(decoded), 2
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
@@ -10,7 +10,7 @@ module JSON
10
10
 
11
11
  def as_json(options = {})
12
12
  # NOTE: Array.new wrapper is requied to avoid CircularReferenceError
13
- {:keys => Array.new(self)}
13
+ {keys: Array.new(self)}
14
14
  end
15
15
  end
16
16
  end
@@ -120,13 +120,26 @@ NrqoxoakrPo1NI1u+ET8oWGmnjB/nJFAPwIDAQAB
120
120
  end
121
121
 
122
122
  context 'when ECDSA' do
123
- it do
124
- JSON::JWK.decode(
125
- kty: :EC,
126
- crv: 'P-256',
127
- x: 'MKBCTNIcKUSDii11ySs3526iDZ8AiTo7Tu6KPAqv7D4',
128
- y: '4Etl6SRW2YiLUrN5vfvVHuhp7x8PxltmWWlbbM4IFyM'
129
- ).should be_instance_of OpenSSL::PKey::EC
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
 
@@ -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.should_receive(:verify)
96
- JSON::JWS.should_receive(:new).and_return(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.alpha2
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-15 00:00:00.000000000 Z
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: 1.3.1
197
+ version: '0'
198
198
  requirements: []
199
199
  rubyforge_project:
200
200
  rubygems_version: 2.2.2