jwt-authorizer 2.0.0 → 2.0.1

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
- SHA256:
3
- metadata.gz: c254092f30d5fb5f9d152e33ae49e915eb102cb831258ba231312e9204d36f24
4
- data.tar.gz: 4ac378bd9ece18fc5cfd4243415b0e820d2c82a48180da5b012120499c60346d
2
+ SHA1:
3
+ metadata.gz: da278a5363a0e712c081dfd198e3c8d362a27517
4
+ data.tar.gz: 776cdc715d65c216e2a0e304b819100057eb23bc
5
5
  SHA512:
6
- metadata.gz: '05694a5caddeef86498257f5768d4f57be2ccc6a41e638c93a5ec8ec7bc202a2d5ba7fa940e326ccaf360f9758f28bfa037d5ed402c820e6ec24c872cca71197'
7
- data.tar.gz: f7689a3b2c287c79e2294eacbbd39a6dcb245272853065b0f3c3264b2d6105dc60cc4849005b7be488cce95cd5658683835d4126f8434131eee12f31a91d692b
6
+ metadata.gz: a6ece519741eae0ef0553e7bda0e893d29e06b88e719925273fc44e047346bb19ce2045d403e550ab21acc07cd24cc8a92d31932748b4181e368431813131490
7
+ data.tar.gz: a645a4f334fdf3d72b6e877af6660c818dc159b376859d712779cfec2dbf7e0f4c6da900d2d4a1f49140cd5d88ecbaea7db4e1355c3ab2bbc0bd6e606daf5610
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
+ ## 2.0.1
2
+
3
+ - Improved error when token configuration is missing private key while signing
4
+ - Allowed empty verifier during claim definition
5
+
1
6
  ## 2.0.0
2
- - Change the way public and private keys are configured, allowing checking JWT signatures against multiple public keys in RSA and ECDSA strategies
7
+
8
+ - Changed the way public and private keys are configured, allowing checking JWT signatures against multiple public keys in RSA and ECDSA strategies
3
9
 
4
10
  ## 1.0.0
5
11
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- jwt-authorizer (2.0.0)
4
+ jwt-authorizer (2.0.1)
5
5
  jwt (~> 2.1)
6
6
 
7
7
  GEM
@@ -14,39 +14,39 @@ GEM
14
14
  jaro_winkler (1.5.1)
15
15
  json (2.1.0)
16
16
  jwt (2.1.0)
17
- method_source (0.9.0)
17
+ method_source (0.9.2)
18
18
  parallel (1.12.1)
19
- parser (2.5.1.0)
19
+ parser (2.5.3.0)
20
20
  ast (~> 2.4.0)
21
21
  powerpack (0.1.2)
22
- pry (0.11.3)
22
+ pry (0.12.0)
23
23
  coderay (~> 1.1.0)
24
24
  method_source (~> 0.9.0)
25
- rack (2.0.5)
25
+ rack (2.0.6)
26
26
  rainbow (3.0.0)
27
27
  rake (12.3.1)
28
- rspec (3.7.0)
29
- rspec-core (~> 3.7.0)
30
- rspec-expectations (~> 3.7.0)
31
- rspec-mocks (~> 3.7.0)
32
- rspec-core (3.7.1)
33
- rspec-support (~> 3.7.0)
34
- rspec-expectations (3.7.0)
28
+ rspec (3.8.0)
29
+ rspec-core (~> 3.8.0)
30
+ rspec-expectations (~> 3.8.0)
31
+ rspec-mocks (~> 3.8.0)
32
+ rspec-core (3.8.0)
33
+ rspec-support (~> 3.8.0)
34
+ rspec-expectations (3.8.2)
35
35
  diff-lcs (>= 1.2.0, < 2.0)
36
- rspec-support (~> 3.7.0)
37
- rspec-mocks (3.7.0)
36
+ rspec-support (~> 3.8.0)
37
+ rspec-mocks (3.8.0)
38
38
  diff-lcs (>= 1.2.0, < 2.0)
39
- rspec-support (~> 3.7.0)
40
- rspec-support (3.7.1)
41
- rubocop (0.57.2)
39
+ rspec-support (~> 3.8.0)
40
+ rspec-support (3.8.0)
41
+ rubocop (0.60.0)
42
42
  jaro_winkler (~> 1.5.1)
43
43
  parallel (~> 1.10)
44
- parser (>= 2.5)
44
+ parser (>= 2.5, != 2.5.1.1)
45
45
  powerpack (~> 0.1)
46
46
  rainbow (>= 2.2.2, < 4.0)
47
47
  ruby-progressbar (~> 1.7)
48
- unicode-display_width (~> 1.0, >= 1.0.1)
49
- ruby-progressbar (1.9.0)
48
+ unicode-display_width (~> 1.4.0)
49
+ ruby-progressbar (1.10.0)
50
50
  simplecov (0.16.1)
51
51
  docile (~> 1.1)
52
52
  json (>= 1.8, < 3)
@@ -70,4 +70,4 @@ DEPENDENCIES
70
70
  timecop (~> 0.9)
71
71
 
72
72
  BUNDLED WITH
73
- 1.16.1
73
+ 1.17.1
data/bin/console CHANGED
@@ -8,7 +8,7 @@ require "jwt/authorizer"
8
8
  # with your gem easier. You can also use a different console, if you like.
9
9
 
10
10
  JWT::Token.configure do |config|
11
- config.secret = "hmac"
11
+ config.hmac.key = "hmac"
12
12
  end
13
13
 
14
14
  require "pry"
@@ -2,6 +2,6 @@
2
2
 
3
3
  module JWT
4
4
  module Authorizer
5
- VERSION = "2.0.0"
5
+ VERSION = "2.0.1"
6
6
  end
7
7
  end
@@ -2,12 +2,20 @@
2
2
 
3
3
  module JWT
4
4
  class Token
5
+ class MissingPrivateKey < StandardError
6
+ def initialize
7
+ super("Private key required for signing tokens is missing!")
8
+ end
9
+ end
10
+
5
11
  module Builder
6
12
  def initialize(claims = {})
7
13
  claims.each { |claim, value| send("#{claim}=", value) }
8
14
  end
9
15
 
10
16
  def to_jwt
17
+ raise MissingPrivateKey unless private_key
18
+
11
19
  JWT.encode claims.compact, private_key, algorithm
12
20
  end; alias to_s to_jwt
13
21
  end
@@ -24,8 +24,9 @@ module JWT
24
24
  def verify(token, context = nil)
25
25
  value = token.send(name)
26
26
 
27
- raise(MissingClaim, key) if required && value.nil?
28
- verifier.call(value, context) if value
27
+ raise(MissingClaim, key) if required && value.nil?
28
+
29
+ verifier.call(value, context) if value && verifier
29
30
  end
30
31
  end
31
32
  end
@@ -73,6 +73,7 @@ module JWT
73
73
 
74
74
  def assert_algorithm_valid(algorithm)
75
75
  return if ALGORITHMS.key?(algorithm.to_s)
76
+
76
77
  raise ArgumentError, "Unknown algorithm: #{algorithm}. Should be one of: #{ALGORITHMS.keys.join(', ')}"
77
78
  end
78
79
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jwt-authorizer
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michał Begejowicz
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-06-28 00:00:00.000000000 Z
11
+ date: 2018-11-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jwt
@@ -191,7 +191,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
191
191
  version: '0'
192
192
  requirements: []
193
193
  rubyforge_project:
194
- rubygems_version: 2.7.6
194
+ rubygems_version: 2.6.14.1
195
195
  signing_key:
196
196
  specification_version: 4
197
197
  summary: Authorization of requests for microservices based on JWT