json-jwt 0.1.8 → 0.2.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/.travis.yml +0 -1
- data/Gemfile.lock +6 -6
- data/VERSION +1 -1
- data/lib/json/jwk.rb +18 -0
- data/spec/json/jwk_spec.rb +30 -0
- metadata +52 -17
data/.travis.yml
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
json-jwt (0.1.
|
4
|
+
json-jwt (0.1.8)
|
5
5
|
activesupport (>= 2.3)
|
6
6
|
i18n
|
7
7
|
json (>= 1.4.3)
|
@@ -10,7 +10,7 @@ PATH
|
|
10
10
|
GEM
|
11
11
|
remote: http://rubygems.org/
|
12
12
|
specs:
|
13
|
-
activesupport (3.2.
|
13
|
+
activesupport (3.2.8)
|
14
14
|
i18n (~> 0.6)
|
15
15
|
multi_json (~> 1.0)
|
16
16
|
configatron (2.9.1)
|
@@ -20,8 +20,8 @@ GEM
|
|
20
20
|
hashie
|
21
21
|
diff-lcs (1.1.3)
|
22
22
|
hashie (1.2.0)
|
23
|
-
i18n (0.6.
|
24
|
-
json (1.7.
|
23
|
+
i18n (0.6.1)
|
24
|
+
json (1.7.5)
|
25
25
|
multi_json (1.3.6)
|
26
26
|
rake (0.9.2.2)
|
27
27
|
rspec (2.11.0)
|
@@ -29,9 +29,9 @@ GEM
|
|
29
29
|
rspec-expectations (~> 2.11.0)
|
30
30
|
rspec-mocks (~> 2.11.0)
|
31
31
|
rspec-core (2.11.1)
|
32
|
-
rspec-expectations (2.11.
|
32
|
+
rspec-expectations (2.11.3)
|
33
33
|
diff-lcs (~> 1.1.3)
|
34
|
-
rspec-mocks (2.11.
|
34
|
+
rspec-mocks (2.11.2)
|
35
35
|
url_safe_base64 (0.2.1)
|
36
36
|
yamler (0.1.0)
|
37
37
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0
|
data/lib/json/jwk.rb
CHANGED
@@ -56,6 +56,24 @@ module JSON
|
|
56
56
|
end
|
57
57
|
hash.merge(options)
|
58
58
|
end
|
59
|
+
|
60
|
+
class << self
|
61
|
+
def decode(jwk)
|
62
|
+
case jwk[:alg]
|
63
|
+
when :RSA
|
64
|
+
exp = OpenSSL::BN.new UrlSafeBase64.decode64(jwk[:exp]), 2
|
65
|
+
mod = OpenSSL::BN.new UrlSafeBase64.decode64(jwk[:mod]), 2
|
66
|
+
key = OpenSSL::PKey::RSA.new
|
67
|
+
key.e = exp
|
68
|
+
key.n = mod
|
69
|
+
key
|
70
|
+
when :EC
|
71
|
+
raise NotImplementedError.new('Not Implemented Yet')
|
72
|
+
else
|
73
|
+
raise UnknownAlgorithm.new('Unknown Algorithm')
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
59
77
|
end
|
60
78
|
end
|
61
79
|
|
data/spec/json/jwk_spec.rb
CHANGED
@@ -61,4 +61,34 @@ describe JSON::JWK do
|
|
61
61
|
end.to raise_error JSON::JWK::UnknownAlgorithm, 'Unknown Algorithm'
|
62
62
|
end
|
63
63
|
end
|
64
|
+
|
65
|
+
describe '.decode' do
|
66
|
+
context 'when RSA' do
|
67
|
+
subject do
|
68
|
+
JSON::JWK.decode(
|
69
|
+
alg: :RSA,
|
70
|
+
mod: mod,
|
71
|
+
exp: exp
|
72
|
+
)
|
73
|
+
end
|
74
|
+
let(:exp) { 'AQAB' }
|
75
|
+
let(:mod) { 'AK8ppaAGn6N3jDic2DhDN5mI5mWzvhfL1AFZOS9q2EBM8L5sjZbYiaHeNoKillZGmEF9a9g6Z20bDnoHTuHPsx93HYkZqPumFZ8K9lLCbqKAMWw2Qgk10RgrZ-kblJotTBCeer9-tZSWO-OWFzP4gp8MpSuQOQbwTJwDgEkFIQLUK2YgzWbn1PoW8xcfbVyWhZD880ELGRW6GhRgYAl0DN_EQS8kyUa0CusYCzOOg2W3-7qjYeojyP6jiOEr-eyjC7hcUvTVoTfz84BiZv72KS3i5JS8ZNNuRp5Ce51wjoDDUoNxDLWv6Da6qMaGpKz6NTSNbvhE_KFhpp4wf5yRQD8=' }
|
76
|
+
let(:pem) do
|
77
|
+
<<-PEM
|
78
|
+
-----BEGIN PUBLIC KEY-----
|
79
|
+
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEArymloAafo3eMOJzYOEM3
|
80
|
+
mYjmZbO+F8vUAVk5L2rYQEzwvmyNltiJod42gqKWVkaYQX1r2DpnbRsOegdO4c+z
|
81
|
+
H3cdiRmo+6YVnwr2UsJuooAxbDZCCTXRGCtn6RuUmi1MEJ56v361lJY745YXM/iC
|
82
|
+
nwylK5A5BvBMnAOASQUhAtQrZiDNZufU+hbzFx9tXJaFkPzzQQsZFboaFGBgCXQM
|
83
|
+
38RBLyTJRrQK6xgLM46DZbf7uqNh6iPI/qOI4Sv57KMLuFxS9NWhN/PzgGJm/vYp
|
84
|
+
LeLklLxk025GnkJ7nXCOgMNSg3EMta/oNrqoxoakrPo1NI1u+ET8oWGmnjB/nJFA
|
85
|
+
PwIDAQAB
|
86
|
+
-----END PUBLIC KEY-----
|
87
|
+
PEM
|
88
|
+
end
|
89
|
+
|
90
|
+
it { should be_instance_of OpenSSL::PKey::RSA }
|
91
|
+
its(:to_pem) { should == pem }
|
92
|
+
end
|
93
|
+
end
|
64
94
|
end
|
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.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-09-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: json
|
16
|
-
requirement:
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,15 @@ dependencies:
|
|
21
21
|
version: 1.4.3
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 1.4.3
|
25
30
|
- !ruby/object:Gem::Dependency
|
26
31
|
name: url_safe_base64
|
27
|
-
requirement:
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
28
33
|
none: false
|
29
34
|
requirements:
|
30
35
|
- - ! '>='
|
@@ -32,10 +37,15 @@ dependencies:
|
|
32
37
|
version: '0'
|
33
38
|
type: :runtime
|
34
39
|
prerelease: false
|
35
|
-
version_requirements:
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
36
46
|
- !ruby/object:Gem::Dependency
|
37
47
|
name: activesupport
|
38
|
-
requirement:
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
39
49
|
none: false
|
40
50
|
requirements:
|
41
51
|
- - ! '>='
|
@@ -43,10 +53,15 @@ dependencies:
|
|
43
53
|
version: '2.3'
|
44
54
|
type: :runtime
|
45
55
|
prerelease: false
|
46
|
-
version_requirements:
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '2.3'
|
47
62
|
- !ruby/object:Gem::Dependency
|
48
63
|
name: i18n
|
49
|
-
requirement:
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
50
65
|
none: false
|
51
66
|
requirements:
|
52
67
|
- - ! '>='
|
@@ -54,10 +69,15 @@ dependencies:
|
|
54
69
|
version: '0'
|
55
70
|
type: :runtime
|
56
71
|
prerelease: false
|
57
|
-
version_requirements:
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
58
78
|
- !ruby/object:Gem::Dependency
|
59
79
|
name: rake
|
60
|
-
requirement:
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
61
81
|
none: false
|
62
82
|
requirements:
|
63
83
|
- - ! '>='
|
@@ -65,10 +85,15 @@ dependencies:
|
|
65
85
|
version: '0.8'
|
66
86
|
type: :development
|
67
87
|
prerelease: false
|
68
|
-
version_requirements:
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0.8'
|
69
94
|
- !ruby/object:Gem::Dependency
|
70
95
|
name: cover_me
|
71
|
-
requirement:
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
72
97
|
none: false
|
73
98
|
requirements:
|
74
99
|
- - ! '>='
|
@@ -76,10 +101,15 @@ dependencies:
|
|
76
101
|
version: 1.2.0
|
77
102
|
type: :development
|
78
103
|
prerelease: false
|
79
|
-
version_requirements:
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: 1.2.0
|
80
110
|
- !ruby/object:Gem::Dependency
|
81
111
|
name: rspec
|
82
|
-
requirement:
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
83
113
|
none: false
|
84
114
|
requirements:
|
85
115
|
- - ! '>='
|
@@ -87,7 +117,12 @@ dependencies:
|
|
87
117
|
version: '2'
|
88
118
|
type: :development
|
89
119
|
prerelease: false
|
90
|
-
version_requirements:
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - ! '>='
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '2'
|
91
126
|
description: JSON Web Token and its family (JSON Web Signature, JSON Web Encryption
|
92
127
|
and JSON Web Key) in Ruby
|
93
128
|
email:
|
@@ -145,7 +180,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
145
180
|
version: '0'
|
146
181
|
requirements: []
|
147
182
|
rubyforge_project:
|
148
|
-
rubygems_version: 1.8.
|
183
|
+
rubygems_version: 1.8.24
|
149
184
|
signing_key:
|
150
185
|
specification_version: 3
|
151
186
|
summary: JSON Web Token and its family (JSON Web Signature, JSON Web Encryption and
|