json-jwt 0.4.1 → 0.4.2
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/Gemfile.lock +2 -4
- data/VERSION +1 -1
- data/json-jwt.gemspec +1 -1
- data/lib/json/jwk.rb +1 -1
- data/lib/json/jwt.rb +3 -3
- data/spec/json/jwk_spec.rb +3 -3
- data/spec/json/jwt_spec.rb +3 -3
- metadata +7 -7
data/Gemfile.lock
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
json-jwt (0.4.
|
4
|
+
json-jwt (0.4.2)
|
5
5
|
activesupport (>= 2.3)
|
6
6
|
i18n
|
7
|
-
|
7
|
+
multi_json (>= 1.3)
|
8
8
|
url_safe_base64
|
9
9
|
|
10
10
|
GEM
|
@@ -21,8 +21,6 @@ GEM
|
|
21
21
|
diff-lcs (1.1.3)
|
22
22
|
hashie (1.2.0)
|
23
23
|
i18n (0.6.1)
|
24
|
-
json (1.7.6)
|
25
|
-
json (1.7.6-java)
|
26
24
|
multi_json (1.5.0)
|
27
25
|
rake (10.0.2)
|
28
26
|
rspec (2.12.0)
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.4.
|
1
|
+
0.4.2
|
data/json-jwt.gemspec
CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |s|
|
|
10
10
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
11
11
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
12
12
|
s.require_paths = ["lib"]
|
13
|
-
s.add_runtime_dependency "
|
13
|
+
s.add_runtime_dependency "multi_json", ">= 1.3"
|
14
14
|
s.add_runtime_dependency "url_safe_base64"
|
15
15
|
s.add_runtime_dependency "activesupport", ">= 2.3"
|
16
16
|
s.add_runtime_dependency "i18n"
|
data/lib/json/jwk.rb
CHANGED
data/lib/json/jwt.rb
CHANGED
@@ -4,7 +4,7 @@ require 'json'
|
|
4
4
|
require 'active_support/core_ext'
|
5
5
|
|
6
6
|
module JSON
|
7
|
-
class JWT <
|
7
|
+
class JWT < ActiveSupport::HashWithIndifferentAccess
|
8
8
|
attr_accessor :header, :signature
|
9
9
|
|
10
10
|
class Exception < StandardError; end
|
@@ -55,7 +55,7 @@ module JSON
|
|
55
55
|
UrlSafeBase64.decode64 segment.to_s
|
56
56
|
end
|
57
57
|
header, claims = [header, claims].collect do |json|
|
58
|
-
|
58
|
+
MultiJson.load(json).with_indifferent_access
|
59
59
|
end
|
60
60
|
signature_base_string = jwt_string.split('.')[0, 2].join('.')
|
61
61
|
jwt = new claims
|
@@ -74,7 +74,7 @@ module JSON
|
|
74
74
|
else
|
75
75
|
raise InvalidFormat.new('Invalid JWT Format. JWT should include 2 or 3 dots.')
|
76
76
|
end
|
77
|
-
rescue
|
77
|
+
rescue MultiJson::DecodeError
|
78
78
|
raise InvalidFormat.new("Invalid JSON Format")
|
79
79
|
end
|
80
80
|
end
|
data/spec/json/jwk_spec.rb
CHANGED
@@ -3,14 +3,14 @@ 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, :e, :n }
|
6
|
+
it { jwk.keys.should include :alg, :e, :n }
|
7
7
|
its(:alg) { jwk[:alg].should == :RSA }
|
8
8
|
its(:e) { jwk[:e].should == UrlSafeBase64.encode64(public_key.e.to_s(2)) }
|
9
9
|
its(:n) { jwk[:n].should == UrlSafeBase64.encode64(public_key.n.to_s(2)) }
|
10
10
|
|
11
11
|
context 'when kid/use options given' do
|
12
12
|
let(:jwk) { JSON::JWK.new public_key, kid: '12345', use: :sig }
|
13
|
-
it { jwk.should include :kid, :use }
|
13
|
+
it { jwk.keys.should include :kid, :use }
|
14
14
|
its(:kid) { jwk[:kid].should == '12345' }
|
15
15
|
its(:use) { jwk[:use].should == :sig }
|
16
16
|
end
|
@@ -36,7 +36,7 @@ describe JSON::JWK do
|
|
36
36
|
[256, 384, 512].each do |digest_length|
|
37
37
|
describe "EC#{digest_length}" do
|
38
38
|
let(:jwk) { JSON::JWK.new public_key(:ecdsa, digest_length: digest_length) }
|
39
|
-
it { jwk.should include :alg, :crv, :x, :y }
|
39
|
+
it { jwk.keys.should include :alg, :crv, :x, :y }
|
40
40
|
its(:alg) { jwk[:alg].should == :EC }
|
41
41
|
its(:x) { jwk[:x].should == expected_coodinates[digest_length][:x] }
|
42
42
|
its(:y) { jwk[:y].should == expected_coodinates[digest_length][:y] }
|
data/spec/json/jwt_spec.rb
CHANGED
@@ -12,8 +12,8 @@ describe JSON::JWT do
|
|
12
12
|
{
|
13
13
|
iss: 'joe',
|
14
14
|
exp: 1300819380,
|
15
|
-
|
16
|
-
}
|
15
|
+
'http://example.com/is_root' => true
|
16
|
+
}.with_indifferent_access
|
17
17
|
end
|
18
18
|
let(:no_signed) do
|
19
19
|
'eyJ0eXAiOiJKV1QiLCJhbGciOiJub25lIn0.eyJpc3MiOiJqb2UiLCJleHAiOjEzMDA4MTkzODAsImh0dHA6Ly9leGFtcGxlLmNvbS9pc19yb290Ijp0cnVlfQ.'
|
@@ -50,7 +50,7 @@ describe JSON::JWT do
|
|
50
50
|
UrlSafeBase64.decode64 segment.to_s
|
51
51
|
end
|
52
52
|
header, claims = [header_base64, claims_base64].collect do |json|
|
53
|
-
|
53
|
+
MultiJson.load(json).with_indifferent_access
|
54
54
|
end
|
55
55
|
jwt = JSON::JWT.new claims
|
56
56
|
jwt.header = header
|
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.
|
4
|
+
version: 0.4.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,16 +9,16 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-01-
|
12
|
+
date: 2013-01-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
|
-
name:
|
15
|
+
name: multi_json
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: 1.
|
21
|
+
version: '1.3'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -26,7 +26,7 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - ! '>='
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: 1.
|
29
|
+
version: '1.3'
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
31
|
name: url_safe_base64
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
@@ -174,7 +174,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
174
174
|
version: '0'
|
175
175
|
segments:
|
176
176
|
- 0
|
177
|
-
hash:
|
177
|
+
hash: 2523711638554282787
|
178
178
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
179
179
|
none: false
|
180
180
|
requirements:
|
@@ -183,7 +183,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
183
183
|
version: '0'
|
184
184
|
segments:
|
185
185
|
- 0
|
186
|
-
hash:
|
186
|
+
hash: 2523711638554282787
|
187
187
|
requirements: []
|
188
188
|
rubyforge_project:
|
189
189
|
rubygems_version: 1.8.24
|