jwt 1.2.0 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (6) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +1 -1
  3. data/jwt.gemspec +3 -3
  4. data/lib/jwt.rb +3 -3
  5. data/spec/jwt_spec.rb +10 -2
  6. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fee3225d7739e1ab161dc39347ac2a20798f8fde
4
- data.tar.gz: 979eb55ee5a17bba062741a6024d11000b45d7fc
3
+ metadata.gz: b05ae75c68fd86cab9446c4ad8df062ed5b226f1
4
+ data.tar.gz: a803c3eaf081008f7c07f3a44d7e2e56d1ecb924
5
5
  SHA512:
6
- metadata.gz: 423bb31cbe9140a3f8d627f87b8131d36d980e9d70dd844a5876a4d91665f145f9e8ac43d5f77f975e180d23387366473c3bc9ff70f31d466e7c3edfd97cdde4
7
- data.tar.gz: ec9d3d47e5e877a8f8b03b2447611b2a1f23c863624827dfa7832bebae40ffcaaff8173da23f10df0a9660fda36ebf7980e306eb3b891091dc31423eea39e6a2
6
+ metadata.gz: 34b8647e6b53bcb0730b43ceba858b8897c9dec71410edc8700e6afbf5dfd142b4caefa6f85963aa691f057bd58a2f0c056a4b91087021e9e5b9cdb75b6a18d0
7
+ data.tar.gz: 182254bae4665e5593a4013750c123932cdd24bf7d2aed821bc626edaaa4dbdc067e2055ce394bab48ec477476ae948ace953b09593877271973120499bad30a
data/Rakefile CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
2
2
  require 'rake'
3
3
  require 'echoe'
4
4
 
5
- Echoe.new('jwt', '1.2.0') do |p|
5
+ Echoe.new('jwt', '1.2.1') 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"
@@ -1,14 +1,14 @@
1
1
  # -*- encoding: utf-8 -*-
2
- # stub: jwt 1.2.0 ruby lib
2
+ # stub: jwt 1.2.1 ruby lib
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "jwt"
6
- s.version = "1.2.0"
6
+ s.version = "1.2.1"
7
7
 
8
8
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
9
9
  s.require_paths = ["lib"]
10
10
  s.authors = ["Jeff Lindsay"]
11
- s.date = "2014-11-24"
11
+ s.date = "2015-01-23"
12
12
  s.description = "JSON Web Token implementation in Ruby"
13
13
  s.email = "progrium@gmail.com"
14
14
  s.extra_rdoc_files = ["lib/jwt.rb", "lib/jwt/json.rb"]
data/lib/jwt.rb CHANGED
@@ -99,19 +99,19 @@ module JWT
99
99
 
100
100
  header, payload, signature, signing_input = decoded_segments(jwt, verify)
101
101
  raise JWT::DecodeError.new("Not enough or too many segments") unless header && payload
102
-
102
+
103
103
  default_options = {
104
104
  :verify_expiration => true,
105
105
  :leeway => 0
106
106
  }
107
107
  options = default_options.merge(options)
108
-
108
+
109
109
  if verify
110
110
  algo, key = signature_algorithm_and_key(header, key, &keyfinder)
111
111
  verify_signature(algo, key, signing_input, signature)
112
112
  end
113
113
  if options[:verify_expiration] && payload.include?('exp')
114
- raise JWT::ExpiredSignature.new("Signature has expired") unless payload['exp'] > (Time.now.to_i - options[:leeway])
114
+ raise JWT::ExpiredSignature.new("Signature has expired") unless payload['exp'].to_i > (Time.now.to_i - options[:leeway])
115
115
  end
116
116
  return payload,header
117
117
  end
@@ -129,7 +129,15 @@ describe JWT do
129
129
  jwt = JWT.encode(expired_payload, secret)
130
130
  expect { JWT.decode(jwt, secret) }.to raise_error(JWT::ExpiredSignature)
131
131
  end
132
-
132
+
133
+ it "raise ExpiredSignature even when exp claims is a string" do
134
+ expired_payload = @payload.clone
135
+ expired_payload['exp'] = (Time.now.to_i).to_s
136
+ secret = "secret"
137
+ jwt = JWT.encode(expired_payload, secret)
138
+ expect { JWT.decode(jwt, secret) }.to raise_error(JWT::ExpiredSignature)
139
+ end
140
+
133
141
  it "performs normal decode with skipped expiration check" do
134
142
  expired_payload = @payload.clone
135
143
  expired_payload['exp'] = Time.now.to_i - 1
@@ -138,7 +146,7 @@ describe JWT do
138
146
  decoded_payload = JWT.decode(jwt, secret, true, {:verify_expiration => false})
139
147
  expect(decoded_payload).to include(expired_payload)
140
148
  end
141
-
149
+
142
150
  it "performs normal decode using leeway" do
143
151
  expired_payload = @payload.clone
144
152
  expired_payload['exp'] = Time.now.to_i - 2
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jwt
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeff Lindsay
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-24 00:00:00.000000000 Z
11
+ date: 2015-01-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: echoe