jwt 1.2.0 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +1 -1
- data/jwt.gemspec +3 -3
- data/lib/jwt.rb +3 -3
- data/spec/jwt_spec.rb +10 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b05ae75c68fd86cab9446c4ad8df062ed5b226f1
|
4
|
+
data.tar.gz: a803c3eaf081008f7c07f3a44d7e2e56d1ecb924
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 34b8647e6b53bcb0730b43ceba858b8897c9dec71410edc8700e6afbf5dfd142b4caefa6f85963aa691f057bd58a2f0c056a4b91087021e9e5b9cdb75b6a18d0
|
7
|
+
data.tar.gz: 182254bae4665e5593a4013750c123932cdd24bf7d2aed821bc626edaaa4dbdc067e2055ce394bab48ec477476ae948ace953b09593877271973120499bad30a
|
data/Rakefile
CHANGED
data/jwt.gemspec
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
# stub: jwt 1.2.
|
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.
|
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 = "
|
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
|
data/spec/jwt_spec.rb
CHANGED
@@ -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.
|
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:
|
11
|
+
date: 2015-01-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: echoe
|