json-jwt 0.5.2 → 0.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

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: 1a480bc0b191d4a57de3c18aee7e779cbe335523
4
- data.tar.gz: be9244d6cf17e9b27922c0d71e48e61d29848c55
3
+ metadata.gz: a9b0839d9f0e6677ee341422becf2dd29c56091c
4
+ data.tar.gz: ad1de154945e36f96b2120c28366e1749bcc600f
5
5
  SHA512:
6
- metadata.gz: 8d87f52f2d640f6eaca57131e351d2cecb4d81533360001960e1be4da0b461efcd0559a5d8d3828db1586fc2774ad38f07ea5d2169eb0fc3b838b7e2b01de166
7
- data.tar.gz: c0bb0d3ac3f4b972cfc484bb58b794f3b392e60706e379cb819f5b4efae39c9bd7bd0c82d636b418958915442cb56ecba2a471833bad961b445585ec8b5a0d1d
6
+ metadata.gz: eb712d0cbfaac919e4ad1f0a26f0785e6de8f61b779dfc1daccc03c2314909c87dc7497c4f18d3e935bab6c306592e3198eb112add0378f5c0c62a7c2a72714a
7
+ data.tar.gz: 607af304e7dec5115cc0b86667315a0ead5eea5b31f539842251d3e1807d06b87685d22ac3c945fa821802e8d3c31f0e0aecb6adba9281949248e2b6975adaf1
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.2
1
+ 0.5.3
@@ -13,7 +13,6 @@ Gem::Specification.new do |s|
13
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
- s.add_runtime_dependency "i18n"
17
16
  s.add_runtime_dependency "bindata"
18
17
  s.add_development_dependency "rake", ">= 0.8"
19
18
  s.add_development_dependency "cover_me", ">= 1.2.0"
@@ -13,7 +13,7 @@ module JSON
13
13
  :master_key, :encrypted_master_key, :encryption_key, :integrity_key
14
14
  )
15
15
 
16
- register_header_keys :enc, :epk, :zip, :jku, :jwk, :x5u, :x5t, :x5c, :kid, :typ, :cty, :apu, :apv, :epu, :epv
16
+ register_header_keys :enc, :epk, :zip, :apu, :apv
17
17
  alias_method :encryption_method, :enc
18
18
 
19
19
  def initialize(input)
@@ -123,8 +123,8 @@ module JSON
123
123
  master_key,
124
124
  encryption_key_size,
125
125
  encryption_method,
126
- epu || 0,
127
- epv || 0,
126
+ 0,
127
+ 0,
128
128
  'Encryption'
129
129
  ]
130
130
  integrity_segments = [
@@ -132,8 +132,8 @@ module JSON
132
132
  master_key,
133
133
  integrity_key_size,
134
134
  encryption_method,
135
- epu || 0,
136
- epv || 0,
135
+ 0,
136
+ 0,
137
137
  'Integrity'
138
138
  ]
139
139
  encryption_hash_input, integrity_hash_input = [encryption_segments, integrity_segments].collect do |segments|
@@ -6,6 +6,10 @@ module JSON
6
6
  replace encode(public_key, options)
7
7
  end
8
8
 
9
+ def content_type
10
+ 'application/jwk+json'
11
+ end
12
+
9
13
  private
10
14
 
11
15
  def ecdsa_curve_name(ecdsa_key)
@@ -4,6 +4,10 @@ module JSON
4
4
  replace Array(jwks).flatten
5
5
  end
6
6
 
7
+ def content_type
8
+ 'application/jwk-set+json'
9
+ end
10
+
7
11
  def as_json(options = {})
8
12
  # NOTE: Array.new wrapper is requied to avoid CircularReferenceError
9
13
  { :keys => Array.new(self) }
@@ -4,8 +4,6 @@ module JSON
4
4
  class VerificationFailed < JWT::VerificationFailed; end
5
5
  class UnexpectedAlgorithm < JWT::UnexpectedAlgorithm; end
6
6
 
7
- register_header_keys :jku, :kid, :x5u, :x5t
8
-
9
7
  def initialize(jwt)
10
8
  replace jwt
11
9
  raise InvalidFormat.new('Signature Algorithm Required') unless algorithm
@@ -28,10 +28,10 @@ module JSON
28
28
  end
29
29
  end
30
30
  end
31
- register_header_keys :typ, :cty, :alg
31
+ register_header_keys :alg, :jku, :jwk, :x5u, :x5t, :x5c, :kid, :typ, :cty, :crit
32
32
  alias_method :algorithm, :alg
33
33
 
34
- def initialize(claims)
34
+ def initialize(claims = {})
35
35
  self.typ = :JWT
36
36
  self.alg = :none
37
37
  [:exp, :nbf, :iat].each do |key|
@@ -62,6 +62,10 @@ module JSON
62
62
  jwe.encrypt! public_key_or_secret
63
63
  end
64
64
 
65
+ def content_type
66
+ "application/#{self.class.name.split('::').last.downcase}"
67
+ end
68
+
65
69
  def to_s
66
70
  [
67
71
  header.to_json,
@@ -8,6 +8,13 @@ describe JSON::JWE do
8
8
  let(:shared_key) { SecureRandom.hex 16 } # default shared key is too short
9
9
  let(:private_key_path) { der_file_path 'rsa/private_key' }
10
10
 
11
+ describe '#content_type' do
12
+ let(:jwe) { JSON::JWE.new 'hello' }
13
+ it do
14
+ jwe.content_type.should == 'application/jwe'
15
+ end
16
+ end
17
+
11
18
  describe 'encrypt!' do
12
19
  shared_examples_for :gcm_encryption do
13
20
  context 'when enc=A128GCM' do
@@ -4,6 +4,12 @@ describe JSON::JWK::Set do
4
4
  let(:jwk) { JSON::JWK.new public_key }
5
5
  let(:set) { JSON::JWK::Set.new jwk }
6
6
 
7
+ describe '#content_type' do
8
+ it do
9
+ set.content_type.should == 'application/jwk-set+json'
10
+ end
11
+ end
12
+
7
13
  context 'when single JWK given' do
8
14
  subject { JSON::JWK::Set.new jwk }
9
15
  it { should == [jwk] }
@@ -1,6 +1,13 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe JSON::JWK do
4
+ describe '#content_type' do
5
+ let(:jwk) { JSON::JWK.new public_key }
6
+ it do
7
+ jwk.content_type.should == 'application/jwk+json'
8
+ end
9
+ end
10
+
4
11
  context 'when RSA public key given' do
5
12
  let(:jwk) { JSON::JWK.new public_key }
6
13
  it { jwk.keys.should include :kty, :e, :n }
@@ -39,6 +39,12 @@ describe JSON::JWS do
39
39
  its(:signature) { should be_nil }
40
40
  end
41
41
 
42
+ describe '#content_type' do
43
+ it do
44
+ jws.content_type.should == 'application/jws'
45
+ end
46
+ end
47
+
42
48
  describe '#sign!' do
43
49
  shared_examples_for :generate_expected_signature do
44
50
  it do
@@ -25,6 +25,12 @@ describe JSON::JWT do
25
25
  end
26
26
  end
27
27
 
28
+ describe '#content_type' do
29
+ it do
30
+ jwt.content_type.should == 'application/jwt'
31
+ end
32
+ end
33
+
28
34
  describe '#sign' do
29
35
  [:HS256, :HS384, :HS512].each do |algorithm|
30
36
  context algorithm do
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.5.2
4
+ version: 0.5.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - nov matake
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-04-05 00:00:00.000000000 Z
11
+ date: 2013-06-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: multi_json
@@ -52,20 +52,6 @@ dependencies:
52
52
  - - '>='
53
53
  - !ruby/object:Gem::Version
54
54
  version: '2.3'
55
- - !ruby/object:Gem::Dependency
56
- name: i18n
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - '>='
60
- - !ruby/object:Gem::Version
61
- version: '0'
62
- type: :runtime
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - '>='
67
- - !ruby/object:Gem::Version
68
- version: '0'
69
55
  - !ruby/object:Gem::Dependency
70
56
  name: bindata
71
57
  requirement: !ruby/object:Gem::Requirement