diff --git a/app/controllers/epp/keyrelays_controller.rb b/app/controllers/epp/keyrelays_controller.rb index d6515758f..81ff3dd32 100644 --- a/app/controllers/epp/keyrelays_controller.rb +++ b/app/controllers/epp/keyrelays_controller.rb @@ -56,4 +56,8 @@ class Epp::KeyrelaysController < EppController # domain end + + def resource + @domain + end end diff --git a/app/controllers/epp/polls_controller.rb b/app/controllers/epp/polls_controller.rb index 531509a6c..fb032975f 100644 --- a/app/controllers/epp/polls_controller.rb +++ b/app/controllers/epp/polls_controller.rb @@ -54,4 +54,8 @@ class Epp::PollsController < EppController def validate_poll requires_attribute 'poll', 'op', values: %(ack req), allow_blank: true end + + def resource + @message + end end diff --git a/app/controllers/epp/sessions_controller.rb b/app/controllers/epp/sessions_controller.rb index c217d38aa..58a314410 100644 --- a/app/controllers/epp/sessions_controller.rb +++ b/app/controllers/epp/sessions_controller.rb @@ -137,4 +137,9 @@ class Epp::SessionsController < EppController pw = params[:parsed_frame].css('pw').first.text { username: user, password: pw } end + + private + def resource + @api_user + end end diff --git a/app/controllers/epp_controller.rb b/app/controllers/epp_controller.rb index 57a5f34d4..e7d3f0ac1 100644 --- a/app/controllers/epp_controller.rb +++ b/app/controllers/epp_controller.rb @@ -13,6 +13,7 @@ class EppController < ApplicationController around_action :catch_epp_errors helper_method :current_user + helper_method :resource def validate_against_schema return if ['hello', 'error', 'keyrelay'].include?(params[:action]) @@ -369,7 +370,7 @@ class EppController < ApplicationController request: trimmed_request, request_command: request_command, request_successful: epp_errors.empty?, - request_object: params[:epp_object_type], + request_object: resource ? "#{params[:epp_object_type]}: #{resource.class} - #{resource.id} - #{resource.name}" : params[:epp_object_type], response: @response, api_user_name: @api_user.try(:username) || current_user.try(:username) || 'api-public', api_user_registrar: @api_user.try(:registrar).try(:to_s) || current_user.try(:registrar).try(:to_s), @@ -385,4 +386,9 @@ class EppController < ApplicationController return if current_user.blank? counter_update(current_user.registrar_code, ENV['iptables_server_ip']) end + + def resource + name = self.class.to_s.sub("Epp::","").sub("Controller","").underscore.singularize + instance_variable_get("@#{name}") + end end diff --git a/config/routes.rb b/config/routes.rb index a041e41b7..39d6b3937 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -7,7 +7,7 @@ Rails.application.routes.draw do post 'command/:action', controller: 'domains', constraints: EppConstraint.new(:domain) post 'command/:action', controller: 'contacts', constraints: EppConstraint.new(:contact) - post 'command/poll', to: 'polls#poll', constraints: EppConstraint.new(:poll) + post 'command/poll', to: 'polls#poll', constraints: EppConstraint.new(:poll) post 'command/keyrelay', to: 'keyrelays#keyrelay', constraints: EppConstraint.new(:keyrelay) post 'command/:command', to: 'errors#not_found', constraints: EppConstraint.new(:not_found) # fallback route