summaryrefslogtreecommitdiff
path: root/app/controllers/health_check_controller.rb
diff options
context:
space:
mode:
authorDJ Mountney <david@twkie.net>2016-05-09 16:21:22 -0700
committerDJ Mountney <david@twkie.net>2016-05-10 08:46:02 -0700
commit160ef66d1bbbbc593516c7575d6b02ddb019c000 (patch)
tree95d2b3e09d56a2237da09c48281201d5ab8d73bf /app/controllers/health_check_controller.rb
parent9898f9b4e6b80edaa914675edfa9b229498b31fe (diff)
downloadgitlab-ce-160ef66d1bbbbc593516c7575d6b02ddb019c000.tar.gz
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