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 +4 -4
- data/lib/zaikio/jwt_auth/directory_cache.rb +10 -3
- data/lib/zaikio/jwt_auth/version.rb +1 -1
- 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: 452c158575a59584224535f6ea124abfa659139e33cb66534cfefe6ac6819916
|
4
|
+
data.tar.gz: c004d38935525597ca3c3c229ddaf5863b467eb326534dc42aeefe153ab1a245
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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.
|
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
|
-
|
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
|
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
|
+
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-
|
13
|
+
date: 2021-04-21 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: oj
|