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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 071ba6ac81c18713dfcf0bcffbe653acc6615df5a20b5ddca96c00c052ee9cff
4
- data.tar.gz: c149da4b8f07c18c5ce3969cfccb8e8287003993624ab154023ddf20ed29b4e9
3
+ metadata.gz: 16addd0eb6fc25b77649cb745c0be9db5fa9eff31f522794a51292506ea9eb72
4
+ data.tar.gz: 5de87ad71baefa6117a048e5cb7e62fb912d5c3f9ebc52dceffc3bc14ccaf8f2
5
5
  SHA512:
6
- metadata.gz: e66155ed93d57af3980075f92126ce498031b4bf7c919812748b08947f4d452a5fe1547232344e6d1d01f61f9e376d9fac26a433f663864b10a8052e802ead72
7
- data.tar.gz: 6e43262184f5e3172bcb5f85ef4f119b035b032623bd3f557a95924fcbfdec432fc8708f0dfdcea99b937194da90412a4ba31da8666b93c52a82ccc29b2597bc
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)
@@ -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.23.0'
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DeepHealthCheck
4
- VERSION = '0.0.3'
4
+ VERSION = '0.0.4'
5
5
  end
@@ -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.3
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-19 00:00:00.000000000 Z
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.23.0
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.23.0
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