zaikio-jwt_auth 1.0.2 → 2.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: 7b3b79eed92b123729aea0048bfcd019ca98bb914430a5d8cd1f081241ef3752
4
- data.tar.gz: d148777cff0767854dfedd703eaf55713666fd6e96d2551f6cd68103f59f52bc
3
+ metadata.gz: c782ad558e422167c59f3c29dfdd9533d97153a17f05955a12eb127e32d55a68
4
+ data.tar.gz: 063fc86f98d24d70e496f324ccc87ec32f71f61ba50c91a70708ca20afe8b1c7
5
5
  SHA512:
6
- metadata.gz: 891bf2b7f94f9ee25878ebd46e49e7e2fcf8e7472d2688e9c00716241199b78ad2d57c14a5ac3b0ff9605ce1059c8be2285c9d97513a192c1eb989ab8ba1ed65
7
- data.tar.gz: d44a02245269d8693380ba6a6e7a389214582848b3264ae5fc2b11678c8d2ba5bb2f77781bb63c85e4c110ec08490fd0f87c309b1770253388a7b76707107d87
6
+ metadata.gz: 4b24750a7edda299537d85f6bf852a85aaba442f77a18d6c9998d3ef491fa1b329b843b23ddc7b2b6f309ab3abac2c94e0448eef2c7370a9a59014e8823add84
7
+ data.tar.gz: 8b39b2cdaa531bb985b59a374584e6ba2d0167213f9e70185be84462843044478026bc74b8d24e972cd840e1a4402a8ff5390245948fd0b3393ebb1ccc31baa7
data/README.md CHANGED
@@ -28,7 +28,9 @@ $ gem install zaikio-jwt_auth
28
28
  Zaikio::JWTAuth.configure do |config|
29
29
  config.environment = :sandbox # or production
30
30
  config.app_name = "test_app" # Your Zaikio App-Name
31
- config.redis = Redis.new
31
+
32
+ # Enable caching Hub API responses for e.g. revoked tokens
33
+ config.cache = Rails.cache
32
34
  end
33
35
  ```
34
36
 
@@ -183,6 +185,13 @@ rescue JWT::DecodeError, JWT::ExpiredSignature
183
185
  end
184
186
  ```
185
187
 
188
+ ### Using a different cache backend
189
+
190
+ This client supports any implementation of
191
+ [`ActiveSupport::Cache::Store`](https://api.rubyonrails.org/classes/ActiveSupport/Cache/Store.html),
192
+ but you can also write your own client that supports these methods: `#read(key)`,
193
+ `#write(key, value)`, `#delete(key)`
194
+
186
195
  ## Contributing
187
196
 
188
197
  **Make sure you have the dummy app running locally to validate your changes.**
@@ -11,7 +11,7 @@ module Zaikio
11
11
  production: "https://hub.zaikio.com"
12
12
  }.freeze
13
13
 
14
- attr_accessor :app_name, :redis, :host
14
+ attr_accessor :app_name, :cache, :host
15
15
  attr_reader :environment
16
16
  attr_writer :logger, :revoked_token_ids, :keys
17
17
 
@@ -16,7 +16,7 @@ module Zaikio
16
16
 
17
17
  class << self
18
18
  def fetch(directory_path, options = {})
19
- cache = Zaikio::JWTAuth.configuration.redis.get("zaikio::jwt_auth::#{directory_path}")
19
+ cache = Zaikio::JWTAuth.configuration.cache.read("zaikio::jwt_auth::#{directory_path}")
20
20
 
21
21
  json = Oj.load(cache) if cache
22
22
 
@@ -31,14 +31,14 @@ module Zaikio
31
31
  def update(directory_path, options = {})
32
32
  data = fetch(directory_path, options)
33
33
  data = yield(data)
34
- Zaikio::JWTAuth.configuration.redis.set("zaikio::jwt_auth::#{directory_path}", {
34
+ Zaikio::JWTAuth.configuration.cache.write("zaikio::jwt_auth::#{directory_path}", {
35
35
  fetched_at: Time.now.to_i,
36
36
  data: data
37
37
  }.to_json)
38
38
  end
39
39
 
40
40
  def reset(directory_path)
41
- Zaikio::JWTAuth.configuration.redis.del("zaikio::jwt_auth::#{directory_path}")
41
+ Zaikio::JWTAuth.configuration.cache.delete("zaikio::jwt_auth::#{directory_path}")
42
42
  end
43
43
 
44
44
  private
@@ -49,7 +49,7 @@ module Zaikio
49
49
 
50
50
  def reload_or_enqueue(directory_path)
51
51
  data = fetch_from_directory(directory_path)
52
- Zaikio::JWTAuth.configuration.redis.set("zaikio::jwt_auth::#{directory_path}", {
52
+ Zaikio::JWTAuth.configuration.cache.write("zaikio::jwt_auth::#{directory_path}", {
53
53
  fetched_at: Time.now.to_i,
54
54
  data: data
55
55
  }.to_json)
@@ -1,5 +1,5 @@
1
1
  module Zaikio
2
2
  module JWTAuth
3
- VERSION = "1.0.2".freeze
3
+ VERSION = "2.0.0".freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zaikio-jwt_auth
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - crispymtn
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2022-04-22 00:00:00.000000000 Z
13
+ date: 2022-04-29 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activejob