jwt_keeper 5.0.1 → 6.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4ce4912150544b5d9944105ef36f43022c480578eb922d6a5f001c2044a53de6
4
- data.tar.gz: 8f1ef7fa13008c88133aac5babbf8622070db55ac3ea49eb45ef515c23e1751b
3
+ metadata.gz: 135ae5f5451cdcd997de5a5208642833ef5d043038b020fc96b67415c243b8b7
4
+ data.tar.gz: f940045097cb8cbd2d281bd1b887598f7c2f0f7bf25e598b834978e61a9337f8
5
5
  SHA512:
6
- metadata.gz: df62c535a49f323772ee6b7fe995ada5a1906c1ac3d80916949a30c7030c058eea47105368edc97351c1853bdf11cf6f561452e21d71d2d79f32246964acf3b5
7
- data.tar.gz: b03abb09f142d3d5b27706b9792be412ea8c5698b4c7c385a343f15cd147cf9b71202c32b24b7dbbd892a9ac054be6918b9562498f7f8a347d30d054d54ddc19
6
+ metadata.gz: dfa8fe29790a114e9f180822f32015fb5881cc268b249b757bec44df0ed419b203e33c27f439ed019cbdeecdbc6aa34512930c4210b5c000a77adb5da6dee07c
7
+ data.tar.gz: 881df471eaa098d00614578f551d2e67414cdee8260c45e7ad90a2cdca71fd2af52b3c88ebd8d9fa61bedaf9863dceaee7281a6f5f92f56b238111bf4b382527
data/README.md CHANGED
@@ -40,6 +40,7 @@ class ApplicationController < ActionController::Base
40
40
  include JWTKeeper::Controller
41
41
 
42
42
  before_action :require_authentication
43
+ rescue_from JWTKeeper::NotAuthenticatedError, with: :not_authenticated
43
44
 
44
45
  def not_authenticated
45
46
  # Overload to return status 401
@@ -10,7 +10,7 @@ module JWTKeeper
10
10
 
11
11
  if token.nil?
12
12
  clear_authentication_token
13
- return not_authenticated
13
+ raise JWTKeeper::NotAuthenticatedError
14
14
  end
15
15
 
16
16
  if token.version_mismatch? || token.pending?
@@ -51,13 +51,6 @@ module JWTKeeper
51
51
  @authentication_token = nil
52
52
  end
53
53
 
54
- # The default action for denying non-authenticated connections.
55
- # You can override this method in your controllers
56
- # @return [void]
57
- def not_authenticated
58
- redirect_to root_path
59
- end
60
-
61
54
  # The default action for accepting authenticated connections.
62
55
  # You can override this method in your controllers
63
56
  # @return [void]
@@ -1,4 +1,7 @@
1
1
  module JWTKeeper
2
+ # the session is invalid
3
+ class NotAuthenticatedError < StandardError; end
4
+
2
5
  # The token is invalid
3
6
  class InvalidTokenError < StandardError; end
4
7
 
@@ -1,4 +1,4 @@
1
1
  # Gem Version
2
2
  module JWTKeeper
3
- VERSION = '5.0.1'.freeze
3
+ VERSION = '6.0.0'.freeze
4
4
  end
@@ -52,7 +52,6 @@ RSpec.describe JWTKeeper do
52
52
  it { is_expected.to respond_to(:read_authentication_token) }
53
53
  it { is_expected.to respond_to(:write_authentication_token) }
54
54
  it { is_expected.to respond_to(:clear_authentication_token) }
55
- it { is_expected.to respond_to(:not_authenticated) }
56
55
  it { is_expected.to respond_to(:authenticated) }
57
56
  it { is_expected.to respond_to(:regenerate_claims) }
58
57
  end
@@ -77,13 +76,9 @@ RSpec.describe JWTKeeper do
77
76
 
78
77
  context 'with expired token' do
79
78
  let(:token) { JWTKeeper::Token.create(exp: 3.hours.ago) }
80
- before do
81
- allow(test_controller).to receive(:not_authenticated)
82
- end
83
79
 
84
- it 'calls not_authenticated' do
85
- subject.require_authentication
86
- expect(subject).to have_received(:not_authenticated).once
80
+ it 'raises NotAuthenticated' do
81
+ expect { subject.require_authentication }.to raise_error(JWTKeeper::NotAuthenticatedError)
87
82
  end
88
83
  end
89
84
 
@@ -162,16 +157,5 @@ RSpec.describe JWTKeeper do
162
157
  expect(subject.response.headers['Authorization']).to be_nil
163
158
  end
164
159
  end
165
-
166
- describe '#not_authenticated' do
167
- before do
168
- allow(test_controller).to receive(:redirect_to)
169
- end
170
-
171
- it 'it calls redirect_to' do
172
- subject.not_authenticated
173
- expect(subject).to have_received(:redirect_to).with('/')
174
- end
175
- end
176
160
  end
177
161
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jwt_keeper
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.0.1
4
+ version: 6.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Rivera
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2021-03-02 00:00:00.000000000 Z
12
+ date: 2021-03-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler