zaikio-jwt_auth 0.4.4 → 0.5.0

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: d7b832b997b8cca7a0fe380edfb7f902f152f317747ea5eb83041dac639d4a31
4
- data.tar.gz: d1f9556f70ce6034472a8cf027d4bd09a043be8967615e097b376b8dfcbff2e4
3
+ metadata.gz: 452c158575a59584224535f6ea124abfa659139e33cb66534cfefe6ac6819916
4
+ data.tar.gz: c004d38935525597ca3c3c229ddaf5863b467eb326534dc42aeefe153ab1a245
5
5
  SHA512:
6
- metadata.gz: 7cb49d476a40bd91701b53cfc196e8db0b7630217f55bcc86acb0c0a012ed318c3abb62099cb268e00be802551ada7e220bb8036982d9a9dc371fd146a97d089
7
- data.tar.gz: affaa752ee97fb676a945dc2a5df3b7b4594289df3900fdc3457ca479096441867e97ba150d88008cb0ee65fc247f055e619b6a37796070c9405a9e85fdcab3f
6
+ metadata.gz: bdb4a90f6fdf5d7a004a1b0342ab40eed28a94fbec8f952601af10f10531213c95dcbe815e077b5bc5f46edf935e2f76317ab27a2349ca44e12ce1eb0ea445e0
7
+ data.tar.gz: ec33d942d728639ccb52052f317a5c7e3d66401296fa69a57f1856e81f044339ee62278c3680ce9d2fadc6d46c0bb38a9b51918edc8fb4a5fe54363283c9aa6f
@@ -5,6 +5,8 @@ require "logger"
5
5
  module Zaikio
6
6
  module JWTAuth
7
7
  class DirectoryCache
8
+ BadResponseError = Class.new(StandardError)
9
+
8
10
  class << self
9
11
  def fetch(directory_path, options = {})
10
12
  cache = Zaikio::JWTAuth.configuration.redis.get("zaikio::jwt_auth::#{directory_path}")
@@ -48,10 +50,10 @@ module Zaikio
48
50
  }.to_json)
49
51
 
50
52
  data
51
- rescue Errno::ECONNREFUSED, Net::ReadTimeout => e
53
+ rescue Errno::ECONNREFUSED, Net::ReadTimeout, BadResponseError => e
52
54
  raise unless (retries += 1) <= 3
53
55
 
54
- Zaikio::JWTAuth.configuration.logger.log("Timeout (#{e}), retrying in 1 second...")
56
+ Zaikio::JWTAuth.configuration.logger.info("Timeout (#{e}), retrying in 1 second...")
55
57
  sleep(1)
56
58
  retry
57
59
  end
@@ -59,7 +61,12 @@ module Zaikio
59
61
 
60
62
  def fetch_from_directory(directory_path)
61
63
  uri = URI("#{Zaikio::JWTAuth.configuration.host}/#{directory_path}")
62
- Oj.load(Net::HTTP.get(uri))
64
+ http = Net::HTTP.new(uri.host, uri.port)
65
+ response = http.request(Net::HTTP::Get.new(uri.request_uri))
66
+ raise BadResponseError unless (200..299).cover?(response.code.to_i)
67
+ raise BadResponseError unless response["content-type"].to_s.include?("application/json")
68
+
69
+ Oj.load(response.body)
63
70
  end
64
71
  end
65
72
  end
@@ -1,5 +1,5 @@
1
1
  module Zaikio
2
2
  module JWTAuth
3
- VERSION = "0.4.4".freeze
3
+ VERSION = "0.5.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: 0.4.4
4
+ version: 0.5.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: 2021-03-29 00:00:00.000000000 Z
13
+ date: 2021-04-21 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: oj