Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDJ Mountney <david@twkie.net>2016-05-10 02:21:22 +0300
committerDJ Mountney <david@twkie.net>2016-05-10 18:46:02 +0300
commit160ef66d1bbbbc593516c7575d6b02ddb019c000 (patch)
tree95d2b3e09d56a2237da09c48281201d5ab8d73bf /app/controllers/health_check_controller.rb
parent9898f9b4e6b80edaa914675edfa9b229498b31fe (diff)
Add health_check access token, and enforce on the health_check endpoint
Also added a health check page to the admin section for resetting the token.
Diffstat (limited to 'app/controllers/health_check_controller.rb')
-rw-r--r--app/controllers/health_check_controller.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/app/controllers/health_check_controller.rb b/app/controllers/health_check_controller.rb
new file mode 100644
index 00000000000..b974489836f
--- /dev/null
+++ b/app/controllers/health_check_controller.rb
@@ -0,0 +1,13 @@
+class HealthCheckController < HealthCheck::HealthCheckController
+ before_action :validate_health_check_access!
+
+ protected
+
+ def validate_health_check_access!
+ return render_404 unless params[:token].presence && params[:token] == current_application_settings.health_check_access_token
+ end
+
+ def render_404
+ render file: Rails.root.join("public", "404"), layout: false, status: "404"
+ end
+end