deep_health_check 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +8 -1
- data/deep_health_check.gemspec +1 -1
- data/lib/deep_health_check/basic_auth_health_check.rb +23 -0
- data/lib/deep_health_check/version.rb +1 -1
- data/lib/deep_health_check.rb +1 -0
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 16addd0eb6fc25b77649cb745c0be9db5fa9eff31f522794a51292506ea9eb72
|
4
|
+
data.tar.gz: 5de87ad71baefa6117a048e5cb7e62fb912d5c3f9ebc52dceffc3bc14ccaf8f2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e1de2527b764d477aa90b8ef2b842e202ab7416dd089b351deb7af40fdeb5c1c54ed7a3d5b02c5ba9e8a232a6eb2f8e6ea7129f1e5c0d7e93add908fa09bf8bf
|
7
|
+
data.tar.gz: 9285c90ce3ed9410c6b6cc73a4350c855df846b8009ffb6fbcf12fbfe2e8e6b03ca6be5fb7102372ecf8a8ef9f283db931627de68ff697bf491ba808f482c694
|
data/README.md
CHANGED
@@ -25,7 +25,14 @@ if other middleware fails when database is down for example ActiveRecord::QueryC
|
|
25
25
|
config.middleware.insert_after "Rails::Rack::Logger", DeepHealthCheck::MiddlewareHealthCheck
|
26
26
|
~~~
|
27
27
|
|
28
|
+
Or for protecting all endpoits with hatauth
|
28
29
|
|
30
|
+
~~~sh
|
31
|
+
# config/application.rb
|
32
|
+
config.middleware.use DeepHealthCheck::BasicAuthHealthCheck do |username, password|
|
33
|
+
username == "$USER" && password == "$PASS"
|
34
|
+
end
|
35
|
+
~~~
|
29
36
|
|
30
37
|
|
31
38
|
# Protect Health Check endpoints using htauth credentials.
|
@@ -45,6 +52,6 @@ Health check middleware expose the following endpoints
|
|
45
52
|
HTTP_DEPENDENCY_00=http://127.0.0.0:8080/health
|
46
53
|
```
|
47
54
|
|
48
|
-
Some of these endpoints provide information about the database and system status. By Default these endpoints are not protected and are accessible publicly. To reduce the security risk introduced by exposing these endpoints, We can protect them using htauth credentials. The following page provide all the necessary steps needed to achieve this task.
|
55
|
+
Some of these endpoints provide information about the database and system status. By Default these endpoints are not protected and are accessible publicly. To reduce the security risk introduced by exposing these endpoints, We can protect them using htauth credentials. The following page provide all the necessary steps needed to achieve this task using nginx.
|
49
56
|
|
50
57
|
[Nginx Configurations](NGINX.md)
|
data/deep_health_check.gemspec
CHANGED
@@ -30,5 +30,5 @@ Gem::Specification.new do |spec|
|
|
30
30
|
spec.add_development_dependency 'rack-test', '~> 1.1', '>= 1.1.0'
|
31
31
|
spec.add_development_dependency 'rake', '~> 13.0'
|
32
32
|
spec.add_development_dependency 'rspec', '~> 3.9', '>= 3.9.0'
|
33
|
-
spec.add_development_dependency 'rubocop', '1.
|
33
|
+
spec.add_development_dependency 'rubocop', '1.24.0'
|
34
34
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module DeepHealthCheck
|
4
|
+
class BasicAuthHealthCheck < Rack::Auth::Basic
|
5
|
+
def call(env)
|
6
|
+
auth = ::Rack::Auth::Basic::Request.new(env)
|
7
|
+
if env['PATH_INFO'].match(/^\/((db|tcp|http)_)?(dependencies_)?health$/)
|
8
|
+
return unauthorized unless auth.provided?
|
9
|
+
return bad_request unless auth.basic?
|
10
|
+
|
11
|
+
if valid?(auth)
|
12
|
+
env['REMOTE_USER'] = auth.username
|
13
|
+
health_check = HealthCheckBuilder.build env['PATH_INFO']
|
14
|
+
return (health_check&.call || @app.call(env))
|
15
|
+
end
|
16
|
+
|
17
|
+
unauthorized
|
18
|
+
else
|
19
|
+
@app.call(env)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/deep_health_check.rb
CHANGED
@@ -8,6 +8,7 @@ require 'deep_health_check/tcp_dependency_health_check'
|
|
8
8
|
require 'deep_health_check/http_dependency_health_check'
|
9
9
|
require 'deep_health_check/health_check_builder'
|
10
10
|
require 'deep_health_check/middleware_health_check'
|
11
|
+
require 'deep_health_check/basic_auth_health_check'
|
11
12
|
|
12
13
|
module DeepHealthCheck
|
13
14
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: deep_health_check
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Al-waleed shihadeh
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-12-
|
11
|
+
date: 2021-12-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -126,14 +126,14 @@ dependencies:
|
|
126
126
|
requirements:
|
127
127
|
- - '='
|
128
128
|
- !ruby/object:Gem::Version
|
129
|
-
version: 1.
|
129
|
+
version: 1.24.0
|
130
130
|
type: :development
|
131
131
|
prerelease: false
|
132
132
|
version_requirements: !ruby/object:Gem::Requirement
|
133
133
|
requirements:
|
134
134
|
- - '='
|
135
135
|
- !ruby/object:Gem::Version
|
136
|
-
version: 1.
|
136
|
+
version: 1.24.0
|
137
137
|
description: Provides a health check API endpoint for rack apps
|
138
138
|
email:
|
139
139
|
- shihadeh.dev@gmail.com
|
@@ -159,6 +159,7 @@ files:
|
|
159
159
|
- bin/travis
|
160
160
|
- deep_health_check.gemspec
|
161
161
|
- lib/deep_health_check.rb
|
162
|
+
- lib/deep_health_check/basic_auth_health_check.rb
|
162
163
|
- lib/deep_health_check/db_health_check.rb
|
163
164
|
- lib/deep_health_check/dependency_health_check.rb
|
164
165
|
- lib/deep_health_check/health_check.rb
|