rack-prx_auth 0.2.0 → 0.2.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
2
  SHA256:
3
- metadata.gz: 1a046d23f5dddd905d482208bedda29f002ccf887e044c55b82be9f02a7b88d4
4
- data.tar.gz: dab3fbad2e08e934cbf9332ea5de21c6f436757fa626095cc1237b558956741d
3
+ metadata.gz: 0e57bda2725fe363d27b499e084653515fba6fdd2dd90af5ea42edce47fa2918
4
+ data.tar.gz: 594cf56ce3d05aa865400dc092a166c4ef1cefb27018c1012116430018045373
5
5
  SHA512:
6
- metadata.gz: d861d3f27fa0b055d219fb582673b6e6e61ab463490cbe5ad27fa7337dc8cb2c1ee1f2a62ef1d229a4d1f7f2b92a6f798cc896b4ff4e65367e2f74d2c24f3cad
7
- data.tar.gz: 90cd78b49457af08f08c3288ac79daffcbfab5c07908c3c2f77989baf2c923e98856999df7964fd206303ec10e6ca2a42c0c299a149a0043325349a0edea6e79
6
+ metadata.gz: 62c7e985124f8809cd0b8afcece43a0107d5f8027740b319dad1a95c7760ea4ff3913c4e0b337beab1dbb5506a45e5ba6d9fbe41ca871b3cdcf3841a9f777a18
7
+ data.tar.gz: 3d5f9d6a398fec46149e1413ad89d8990a9bc16b335f2aed1b3918f4e5ffdaa1545b9ecab89392a795dad48d267d0d464c2393be3a9f0639ac42c5f62a49640c
@@ -43,6 +43,8 @@ module Rack
43
43
  end
44
44
 
45
45
  def decode_token(token)
46
+ return {} if token.nil?
47
+
46
48
  begin
47
49
  JSON::JWT.decode(token, :skip_verification)
48
50
  rescue JSON::JWT::InvalidFormat
@@ -1,5 +1,5 @@
1
1
  module Rack
2
2
  class PrxAuth
3
- VERSION = "0.2.0"
3
+ VERSION = "0.2.1"
4
4
  end
5
5
  end
@@ -26,6 +26,11 @@ describe Rack::PrxAuth do
26
26
  prxauth.call(env.clone).must_equal env
27
27
  end
28
28
 
29
+ it 'does nothing if the token is nil' do
30
+ env = {"HTTP_AUTHORIZATION"=>"Bearer "}
31
+ prxauth.call(env).must_equal env
32
+ end
33
+
29
34
  it 'returns 401 if verification fails' do
30
35
  JSON::JWT.stub(:decode, claims) do
31
36
  prxauth.stub(:valid?, false) do
@@ -76,4 +81,18 @@ describe Rack::PrxAuth do
76
81
  end
77
82
  end
78
83
  end
84
+
85
+ describe '#decode_token' do
86
+ it 'should return an empty result for a nil token' do
87
+ prxauth.send(:decode_token, nil).must_equal({})
88
+ end
89
+
90
+ it 'should return an empty result for an empty token' do
91
+ prxauth.send(:decode_token, {}).must_equal({})
92
+ end
93
+
94
+ it 'should return an empty result for a malformed token' do
95
+ prxauth.send(:decode_token, 'asdfsadfsad').must_equal({})
96
+ end
97
+ end
79
98
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-prx_auth
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eve Asher
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2019-06-25 00:00:00.000000000 Z
12
+ date: 2019-07-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler