rack-auditor 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/lib/rack/auditor.rb +21 -23
- data/rack-auditor.gemspec +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NzQ4NTRlM2QwYTllMzk5OWY2YWQxZDliMzMxNzkyMmVkZTgyYmM0YQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NmI4NDhiZDEzZTEwNTg4MWU3ZjI2ZmI2NDlkNjFjYmVjMGQwNjIzZA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
YWQ4ZTYyMGYzNTM5NTU4ODEyODE0MDFiYzJkODhjNTViZWVlMjBmOWEzMWEy
|
10
|
+
NzE3MDc4MzMyMWMwMzMzYTQwMDBlYTdhYzBhZjZiNDhmODRmYjEzMDA3YzRl
|
11
|
+
NTI1YzY5YTRjNWMxMjQ4YTRmYjlkZTY3ZDNiODM4YzRhYjNhZTE=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NWQ3OWM0ZWE0MzU4YzQzYTBjNzk0NTA3Y2Q1NWQ2YzRmNjVhYzQ2OGJjMGZi
|
14
|
+
MTY3OTdmYmFjNzI1YzA3ODljOWU4NTEzZjI5ZTBmMjM2ZTI4YWZkN2JiMTAw
|
15
|
+
MTIxMzZjNDRlNmE3ODUwMzM3Y2VjYzEzMDU5NzdkYTZmNDJmODQ=
|
data/lib/rack/auditor.rb
CHANGED
@@ -9,33 +9,31 @@ module Rack
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def call(env)
|
12
|
-
|
12
|
+
unless @dev_mode
|
13
|
+
key = env['HTTP_X_API_KEY']
|
14
|
+
secret = env['HTTP_X_API_SECRET']
|
15
|
+
|
16
|
+
return forbidden unless key && secret
|
17
|
+
|
18
|
+
response = HTTParty.get "#{@root_uri}?api_key=#{key}&api_secret=#{secret}"
|
19
|
+
|
20
|
+
case response.code
|
21
|
+
when 403
|
22
|
+
forbidden
|
23
|
+
when 404
|
24
|
+
error_code(404, 'Not Found')
|
25
|
+
when 500
|
26
|
+
error_code(500, 'Server Error')
|
27
|
+
when 503
|
28
|
+
error_code(503, 'Maintenance')
|
29
|
+
when 504
|
30
|
+
error_code(504, 'System Down')
|
31
|
+
end
|
32
|
+
end
|
13
33
|
|
14
34
|
@app.call(env)
|
15
35
|
end
|
16
36
|
|
17
|
-
def audit(env)
|
18
|
-
key = env['HTTP_X_API_KEY']
|
19
|
-
secret = env['HTTP_X_API_SECRET']
|
20
|
-
|
21
|
-
return forbidden unless key && secret
|
22
|
-
|
23
|
-
response = HTTParty.get "#{@root_uri}?api_key=#{key}&api_secret=#{secret}"
|
24
|
-
|
25
|
-
case response.code
|
26
|
-
when 403
|
27
|
-
forbidden
|
28
|
-
when 404
|
29
|
-
error_code(404, 'Not Found')
|
30
|
-
when 500
|
31
|
-
error_code(500, 'Server Error')
|
32
|
-
when 503
|
33
|
-
error_code(503, 'Maintenance')
|
34
|
-
when 504
|
35
|
-
error_code(504, 'System Down')
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
37
|
private
|
40
38
|
def forbidden
|
41
39
|
error_code(403, 'Unauthorized')
|
data/rack-auditor.gemspec
CHANGED