jwt_keeper 6.1.0 → 6.1.2

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: d6ad212dc01831b9bae31adab98ba2edbe1fd803923e32eb9817e2b96515c706
4
- data.tar.gz: c6ef8deb150ffeed569d4da108ac745a907c8bfc065c5564cd49b6aff978f00e
3
+ metadata.gz: 2eeb8151e6cc1c98e0f6615305749ab7dec8528f1182df090e4894850a9107b5
4
+ data.tar.gz: 9226fc5af895edbb1c7516ac4702de326f7a351f167892eb1c9400d758e5d2d1
5
5
  SHA512:
6
- metadata.gz: 87f73d56ceb956a78337d4df685ac8fb86b6eda03046ba137f92f689eb10b5485103f9ea003ccdb7643149b4e74722d674571ec698e8eed40eb0a2d3b1b2feb2
7
- data.tar.gz: 7695c3ce514f9e150d492766b90e7b76e04cb5c496e422aa265d6f255a311e72d986319f169fc0bb5919a42fbe4cb364da700bfeb42fb947bfdb9a6841c5c280
6
+ metadata.gz: 3651f6005aa6bbcbf5f0860bdffad0b1d3e0efa019234ec141c6d6d0f1e548fed86980b2ef78fb3fd899a5a358d43de9fb646688c889b9b9153242df8acd844e
7
+ data.tar.gz: 98cd11cf2e8b669941a39a64a5cc8c233a43fbe985eadf46103a57cbe7e2104281545caab0ea528f72e74345ad1a7a28da688557f90ef08981b21de911345e9f
@@ -63,6 +63,12 @@ module JWTKeeper
63
63
  Datastore.revoke(token_jti, JWTKeeper.configuration.expiry.from_now.to_i)
64
64
  end
65
65
 
66
+ # Checks if a web token has been revoked
67
+ # @return [Boolean]
68
+ def self.revoked?(token_jti)
69
+ Datastore.revoked?(token_jti)
70
+ end
71
+
66
72
  # Easy interface for using the token's id
67
73
  # @return [String] token's uuid
68
74
  def id
@@ -1,4 +1,4 @@
1
1
  # Gem Version
2
2
  module JWTKeeper
3
- VERSION = '6.1.0'.freeze
3
+ VERSION = '6.1.2'.freeze
4
4
  end
data/lib/jwt_keeper.rb CHANGED
@@ -1,5 +1,4 @@
1
1
  require 'jwt'
2
- require 'redis'
3
2
  require 'active_support'
4
3
  require 'active_support/core_ext/numeric'
5
4
 
@@ -108,6 +108,26 @@ module JWTKeeper
108
108
  end
109
109
  end
110
110
 
111
+ describe '.revoked?' do
112
+ let(:token_jti) { SecureRandom.uuid }
113
+
114
+ context 'with a revoked token' do
115
+ before { described_class.revoke(token_jti) }
116
+
117
+ it { expect(described_class.revoked?(token_jti)).to be true }
118
+ end
119
+
120
+ context 'with a pending token' do
121
+ before { described_class.rotate(token_jti) }
122
+
123
+ it { expect(described_class.revoked?(token_jti)).to be false }
124
+ end
125
+
126
+ context 'with a valid token' do
127
+ it { expect(described_class.revoked?(token_jti)).to be false }
128
+ end
129
+ end
130
+
111
131
  describe '.rotate' do
112
132
  subject(:token) { described_class.create(private_claims) }
113
133
  before(:each) { described_class.rotate(token.id) }
data/spec/spec_helper.rb CHANGED
@@ -11,6 +11,8 @@ end
11
11
 
12
12
  require 'rails'
13
13
  require 'jwt_keeper'
14
+ require 'redis-client'
15
+ require 'redis'
14
16
 
15
17
  RSpec.configure do |config|
16
18
  config.expect_with :rspec do |expectations|
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: 6.1.0
4
+ version: 6.1.2
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: 2023-02-09 00:00:00.000000000 Z
12
+ date: 2023-03-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler