jwt_easy 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +11 -1
- data/jwt_easy.gemspec +1 -1
- data/lib/jwt_easy/configuration.rb +2 -1
- data/lib/jwt_easy/decoder.rb +18 -3
- data/lib/jwt_easy/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5feecdc9d32b373d41d65656b566987721ebbdf9
|
4
|
+
data.tar.gz: 2b449cd4efeb08e6ce7c3bd10e2b88afa2a88a87
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 710657ff220ea7e5be8adf76549810d90c2fcbc54f5b5bffa81664875bcaad2a2127553431c5d7cbc64b345cdb386400a6f3c008c42ace094c84ba6f5a4ac4a3
|
7
|
+
data.tar.gz: bdd4ddf8f0a71255fcacca95931332be7307bbe02928df98bc0447958b947b42196ff71da2fd355fbc17926701334e7a237bd7a21e6d617bc6ed37620af5e89e
|
data/README.md
CHANGED
@@ -29,6 +29,16 @@ Of course you're able to consume tokens just as easily:
|
|
29
29
|
JWTEasy.decode(token).id #=> 'some-identifying-information'
|
30
30
|
```
|
31
31
|
|
32
|
+
### Adding Leeway
|
33
|
+
|
34
|
+
For both EXP and NBF claims, you're able to specify the leeway to be used when decoding tokens:
|
35
|
+
|
36
|
+
```ruby
|
37
|
+
JWTEasy.configure do |config|
|
38
|
+
config.leeway = 30 # seconds
|
39
|
+
end
|
40
|
+
````
|
41
|
+
|
32
42
|
## Installation
|
33
43
|
|
34
44
|
Add this line to your application's Gemfile:
|
@@ -53,4 +63,4 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
53
63
|
|
54
64
|
## Contributing
|
55
65
|
|
56
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/lshepstone/
|
66
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/lshepstone/jwt-easy.
|
data/jwt_easy.gemspec
CHANGED
@@ -13,7 +13,7 @@ Gem::Specification.new do |spec|
|
|
13
13
|
|
14
14
|
spec.summary = 'jwt_easy'
|
15
15
|
spec.description = 'Library for generating and consuming JSON web tokens easily.'
|
16
|
-
spec.homepage = 'https://github.com/lshepstone/
|
16
|
+
spec.homepage = 'https://github.com/lshepstone/jwt-easy'
|
17
17
|
spec.license = 'MIT'
|
18
18
|
|
19
19
|
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
data/lib/jwt_easy/decoder.rb
CHANGED
@@ -42,14 +42,29 @@ module JWTEasy
|
|
42
42
|
def headers
|
43
43
|
@headers.tap do |headers|
|
44
44
|
headers[:algorithm] = configuration.algorithm if verification?
|
45
|
-
|
46
45
|
case configuration.claim
|
47
46
|
when CLAIM_EXPIRATION_TIME
|
48
|
-
headers
|
47
|
+
headers.merge!(exp_headers)
|
49
48
|
when CLAIM_NOT_BEFORE_TIME
|
50
|
-
headers
|
49
|
+
headers.merge!(nbf_headers)
|
51
50
|
end
|
52
51
|
end
|
53
52
|
end
|
53
|
+
|
54
|
+
private
|
55
|
+
|
56
|
+
def exp_headers
|
57
|
+
{}.tap do |headers|
|
58
|
+
headers[:validate_exp] = true
|
59
|
+
headers[:exp_leeway] = configuration.leeway if configuration.leeway
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def nbf_headers
|
64
|
+
{}.tap do |headers|
|
65
|
+
headers[:validate_nbf] = true
|
66
|
+
headers[:nbf_leeway] = configuration.leeway if configuration.leeway
|
67
|
+
end
|
68
|
+
end
|
54
69
|
end
|
55
70
|
end
|
data/lib/jwt_easy/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jwt_easy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lawrance Shepstone
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-09-
|
11
|
+
date: 2017-09-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jwt
|
@@ -134,7 +134,7 @@ files:
|
|
134
134
|
- lib/jwt_easy/encoder.rb
|
135
135
|
- lib/jwt_easy/result.rb
|
136
136
|
- lib/jwt_easy/version.rb
|
137
|
-
homepage: https://github.com/lshepstone/
|
137
|
+
homepage: https://github.com/lshepstone/jwt-easy
|
138
138
|
licenses:
|
139
139
|
- MIT
|
140
140
|
metadata: {}
|