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 +4 -4
- data/README.md +1 -0
- data/lib/jwt_keeper/controller.rb +1 -8
- data/lib/jwt_keeper/exceptions.rb +3 -0
- data/lib/jwt_keeper/version.rb +1 -1
- data/spec/lib/jwt_keeper/controller_spec.rb +2 -18
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 135ae5f5451cdcd997de5a5208642833ef5d043038b020fc96b67415c243b8b7
|
4
|
+
data.tar.gz: f940045097cb8cbd2d281bd1b887598f7c2f0f7bf25e598b834978e61a9337f8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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]
|
data/lib/jwt_keeper/version.rb
CHANGED
@@ -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 '
|
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:
|
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-
|
12
|
+
date: 2021-03-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|