19095: Link build script doc page.
[arvados.git] / services / api / app / controllers / arvados / v1 / healthcheck_controller.rb
index 47b49ff46adff90ae20b3b8831e7d2339aa73819..c56208207787526b8089239c50a31f34b1cafa23 100644 (file)
@@ -3,33 +3,34 @@
 # SPDX-License-Identifier: AGPL-3.0
 
 class Arvados::V1::HealthcheckController < ApplicationController
-  skip_before_filter :catch_redirect_hint
-  skip_before_filter :find_objects_for_index
-  skip_before_filter :find_object_by_uuid
-  skip_before_filter :load_filters_param
-  skip_before_filter :load_limit_offset_order_params
-  skip_before_filter :load_read_auths
-  skip_before_filter :load_where_param
-  skip_before_filter :render_404_if_no_object
-  skip_before_filter :require_auth_scope
+  skip_before_action :catch_redirect_hint
+  skip_before_action :find_objects_for_index
+  skip_before_action :find_object_by_uuid
+  skip_before_action :load_filters_param
+  skip_before_action :load_limit_offset_order_params
+  skip_before_action :load_select_param
+  skip_before_action :load_read_auths
+  skip_before_action :load_where_param
+  skip_before_action :render_404_if_no_object
+  skip_before_action :require_auth_scope
 
-  before_filter :check_auth_header
+  before_action :check_auth_header
 
   def check_auth_header
-    mgmt_token = Rails.configuration.management_token
+    mgmt_token = Rails.configuration.ManagementToken
     auth_header = request.headers['Authorization']
 
-    if !mgmt_token
-      send_error("disabled", status: 404)
+    if mgmt_token == ""
+      send_json ({"errors" => "disabled"}), status: 404
     elsif !auth_header
-      send_error("authorization required", status: 401)
+      send_json ({"errors" => "authorization required"}), status: 401
     elsif auth_header != 'Bearer '+mgmt_token
-      send_error("authorization error", status: 403)
+      send_json ({"errors" => "authorization error"}), status: 403
     end
   end
 
   def ping
-    resp = {"health": "OK"}
+    resp = {"health" => "OK"}
     send_json resp
   end
 end