diff --git a/app/controllers/eeid/webhooks/identification_requests_controller.rb b/app/controllers/eeid/webhooks/identification_requests_controller.rb index 1c82969d6..0eb45c4e1 100644 --- a/app/controllers/eeid/webhooks/identification_requests_controller.rb +++ b/app/controllers/eeid/webhooks/identification_requests_controller.rb @@ -10,6 +10,7 @@ module Eeid rescue_from Shunter::ThrottleError, with: :handle_throttle_error # POST /eeid/webhooks/identification_requests + def create return render_unauthorized unless ip_whitelisted? return render_invalid_signature unless valid_hmac_signature?(request.headers['X-HMAC-Signature']) @@ -17,8 +18,7 @@ module Eeid verify_contact(permitted_params[:reference]) render json: { status: 'success' }, status: :ok rescue StandardError => e - Rails.logger.error("Error handling webhook: #{e.message}") - render json: { error: 'Internal Server Error' }, status: :internal_server_error + handle_error(e) end private @@ -64,6 +64,11 @@ module Eeid OpenStruct.new(id: request.remote_ip, class: 'WebhookRequest') end + def handle_error(error) + Rails.logger.error("Error handling webhook: #{error.message}") + render json: { error: 'Internal Server Error' }, status: :internal_server_error + end + def handle_throttle_error render json: { error: Shunter.default_error_message }, status: :bad_request end diff --git a/config/application.yml.sample b/config/application.yml.sample index 8e35d74fe..31d6cdae7 100644 --- a/config/application.yml.sample +++ b/config/application.yml.sample @@ -259,3 +259,7 @@ allow_accr_endspoints: 'true' whitelist_companies: - '12345678' - '87654321' + +eeid_base_url: 'http://eid.test' +ident_service_client_id: 123 +ident_service_client_secret: 321