jwt 0.1.6 → 0.1.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. data/Rakefile +2 -2
  2. data/jwt.gemspec +5 -5
  3. data/lib/jwt.rb +1 -1
  4. data/spec/jwt_spec.rb +7 -0
  5. metadata +4 -4
data/Rakefile CHANGED
@@ -2,13 +2,13 @@ require 'rubygems'
2
2
  require 'rake'
3
3
  require 'echoe'
4
4
 
5
- Echoe.new('jwt', '0.1.6') do |p|
5
+ Echoe.new('jwt', '0.1.7') do |p|
6
6
  p.description = "JSON Web Token implementation in Ruby"
7
7
  p.url = "http://github.com/progrium/ruby-jwt"
8
8
  p.author = "Jeff Lindsay"
9
9
  p.email = "progrium@gmail.com"
10
10
  p.ignore_pattern = ["tmp/*"]
11
- p.runtime_dependencies = ["multi_json >=1.0"]
11
+ p.runtime_dependencies = ["multi_json >=1.5"]
12
12
  p.development_dependencies = ["echoe >=4.6.3"]
13
13
  end
14
14
 
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "jwt"
5
- s.version = "0.1.6"
5
+ s.version = "0.1.7"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Jeff Lindsay"]
9
- s.date = "2013-03-05"
9
+ s.date = "2013-03-07"
10
10
  s.description = "JSON Web Token implementation in Ruby"
11
11
  s.email = "progrium@gmail.com"
12
12
  s.extra_rdoc_files = ["lib/jwt.rb"]
@@ -22,14 +22,14 @@ Gem::Specification.new do |s|
22
22
  s.specification_version = 3
23
23
 
24
24
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
25
- s.add_runtime_dependency(%q<multi_json>, [">= 1.0"])
25
+ s.add_runtime_dependency(%q<multi_json>, [">= 1.5"])
26
26
  s.add_development_dependency(%q<echoe>, [">= 4.6.3"])
27
27
  else
28
- s.add_dependency(%q<multi_json>, [">= 1.0"])
28
+ s.add_dependency(%q<multi_json>, [">= 1.5"])
29
29
  s.add_dependency(%q<echoe>, [">= 4.6.3"])
30
30
  end
31
31
  else
32
- s.add_dependency(%q<multi_json>, [">= 1.0"])
32
+ s.add_dependency(%q<multi_json>, [">= 1.5"])
33
33
  s.add_dependency(%q<echoe>, [">= 4.6.3"])
34
34
  end
35
35
  end
data/lib/jwt.rb CHANGED
@@ -67,7 +67,7 @@ module JWT
67
67
  header = MultiJson.decode(base64url_decode(header_segment))
68
68
  payload = MultiJson.decode(base64url_decode(payload_segment))
69
69
  signature = base64url_decode(crypto_segment) if verify
70
- rescue JSON::ParserError
70
+ rescue MultiJson::LoadError => e
71
71
  raise JWT::DecodeError.new("Invalid segment encoding")
72
72
  end
73
73
  if verify == true
@@ -37,6 +37,13 @@ describe JWT do
37
37
  decoded_payload.should == example_payload
38
38
  end
39
39
 
40
+ it "raises exception when the token is invalid" do
41
+ example_secret = 'secret'
42
+ # Same as above exmaple with some random bytes replaced
43
+ example_jwt = 'eyJhbGciOiAiSFMyNTYiLCAidHiMomlwIjogIkJ9.eyJoZWxsbyI6ICJ3b3JsZCJ9.tvagLDLoaiJKxOKqpBXSEGy7SYSifZhjntgm9ctpyj8'
44
+ lambda { JWT.decode(example_jwt, example_secret) }.should raise_error(JWT::DecodeError)
45
+ end
46
+
40
47
  it "raises exception with wrong hmac key" do
41
48
  right_secret = 'foo'
42
49
  bad_secret = 'bar'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jwt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
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: 2013-03-05 00:00:00.000000000 Z
12
+ date: 2013-03-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: multi_json
@@ -18,7 +18,7 @@ dependencies:
18
18
  requirements:
19
19
  - - ! '>='
20
20
  - !ruby/object:Gem::Version
21
- version: '1.0'
21
+ version: '1.5'
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.0'
29
+ version: '1.5'
30
30
  - !ruby/object:Gem::Dependency
31
31
  name: echoe
32
32
  requirement: !ruby/object:Gem::Requirement