health-monitor-rails 0.0.17 → 0.0.18

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
  SHA1:
3
- metadata.gz: 563cf0fa94dd2ec7824ae8baf3b6f61d6ee53141
4
- data.tar.gz: df72e67e1c744f743d6e1837058e5f10e33defb7
3
+ metadata.gz: 2d9ca6fb1d552400da00021ab3c8bfb66f311b25
4
+ data.tar.gz: 862544d6a13134de1ca23edc2ebe203efb024e2f
5
5
  SHA512:
6
- metadata.gz: f04b15988539a906888fb6abd94f63f4c41451693bb21b38203c24e5c73ec01a723d068c29c221cbd9a2e7be3cae8a0b7ee37e30fbc12d5b568b9071f6baa536
7
- data.tar.gz: e00731b1c99acd1071cdb231338c0dd1311d2e5677c183f8f8efc0c5d497c177d57a4a8d0a63b4ae0ea1aed86d8856cc5b728024bf29f3e750113efd3be14978
6
+ metadata.gz: bc601bd99b8a8ace298a6a73c0a59c4a60b894078a52ed353246c3b94b72ea9d399c7b2916806ee7e9b23dd9fa814429764b964419fb6465e203be4d76cd1dde
7
+ data.tar.gz: b7e8d9dbd8b2fa01fdd5826b09d8ff895954e87aa89364650c8d5798f6b7f851b401f827f2796d49390565402132b6fd0c55e990d9196c547214739a7d16b3c3
data/README.md CHANGED
@@ -75,6 +75,18 @@ HealthMonitor.configure do |config|
75
75
  end
76
76
  ```
77
77
 
78
+ ### Adding authentication credentials
79
+ By default, the `/check` endpoint is not authenticated and is available to any user. You can authenticate using HTTP Basic Auth by providing authentication credentials:
80
+
81
+ ```ruby
82
+ HealthMonitor.configure do |config|
83
+ config.basic_auth_credentials = {
84
+ username: 'SECRET_NAME',
85
+ password: 'Shhhhh!!!'
86
+ }
87
+ end
88
+ ```
89
+
78
90
  ## License
79
91
 
80
92
  The MIT License (MIT)
@@ -1,6 +1,11 @@
1
1
  module HealthMonitor
2
2
  class HealthController < ActionController::Metal
3
- # GET /health/check
3
+ include AbstractController::Callbacks
4
+ include ActionController::HttpAuthentication::Basic::ControllerMethods
5
+
6
+ before_action :authenticate_with_basic_auth
7
+
8
+ # GET /health/check
4
9
  def check
5
10
  HealthMonitor.check!
6
11
 
@@ -19,5 +24,14 @@ module HealthMonitor
19
24
  end
20
25
 
21
26
  alias_method_chain :process, :silence
27
+
28
+ def authenticate_with_basic_auth
29
+ return true unless HealthMonitor.configuration.basic_auth_credentials
30
+
31
+ credentials = HealthMonitor.configuration.basic_auth_credentials
32
+ authenticate_or_request_with_http_basic do |name, password|
33
+ name == credentials[:username] && password == credentials[:password]
34
+ end
35
+ end
22
36
  end
23
37
  end
@@ -1,6 +1,6 @@
1
1
  module HealthMonitor
2
2
  class Configuration
3
- attr_accessor :providers, :error_callback
3
+ attr_accessor :providers, :error_callback, :basic_auth_credentials
4
4
 
5
5
  def initialize
6
6
  @providers = [:database]
@@ -1,3 +1,3 @@
1
1
  module HealthMonitor
2
- VERSION = '0.0.17'.freeze
2
+ VERSION = '0.0.18'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: health-monitor-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.17
4
+ version: 0.0.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - Leonid Beder
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-29 00:00:00.000000000 Z
11
+ date: 2014-09-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails