jwt_easy 0.1.0 → 0.2.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9e7c1abc2e2e5159abc61e45102226fe2b252f9b
4
- data.tar.gz: 7c393cced4e3786d6b5834855716827d69890671
3
+ metadata.gz: 5feecdc9d32b373d41d65656b566987721ebbdf9
4
+ data.tar.gz: 2b449cd4efeb08e6ce7c3bd10e2b88afa2a88a87
5
5
  SHA512:
6
- metadata.gz: 9159765198fcb834e2a316b54f1eed749118cf90d1dfe89f9dc7884b9267e12705e0d9090f997b551d14d6d9dcdae2a9ef1374c21d9ae835d5c8f7416f7792e6
7
- data.tar.gz: 26dfb051ded825aa7d6df8bf4bb4758c60cceff754f7b5fe7588e1fb520688d9a2330181187bafda0b8be5eb582cf79e9ee24aff5149eee34249e55bd959f006
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/jwt_easy.
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/jwt_easy'
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|
@@ -10,7 +10,8 @@ module JWTEasy
10
10
 
11
11
  attr_accessor :secret,
12
12
  :expiration_time,
13
- :not_before_time
13
+ :not_before_time,
14
+ :leeway
14
15
 
15
16
  # Gets the algorithm to use when encoding tokens
16
17
  #
@@ -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[:validate_exp] = true
47
+ headers.merge!(exp_headers)
49
48
  when CLAIM_NOT_BEFORE_TIME
50
- headers[:validate_nbf] = true
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module JWTEasy
4
- VERSION = '0.1.0'
4
+ VERSION = '0.2.0'
5
5
  end
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.1.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-01 00:00:00.000000000 Z
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/jwt_easy
137
+ homepage: https://github.com/lshepstone/jwt-easy
138
138
  licenses:
139
139
  - MIT
140
140
  metadata: {}