mirror of
https://github.com/internetee/registry.git
synced 2025-05-17 01:47:18 +02:00
EPP Request logging
This commit is contained in:
parent
1b3f27e01d
commit
d5a824064e
7 changed files with 66 additions and 2 deletions
|
@ -9,6 +9,7 @@ module Epp::Common
|
|||
included do
|
||||
protect_from_forgery with: :null_session
|
||||
before_action :validate_request, only: [:proxy]
|
||||
after_action :log_to_epp_log
|
||||
|
||||
helper_method :current_epp_user
|
||||
end
|
||||
|
@ -112,4 +113,16 @@ module Epp::Common
|
|||
return unless respond_to?(validation_method, true)
|
||||
handle_errors and return unless send(validation_method)
|
||||
end
|
||||
|
||||
def log_to_epp_log
|
||||
ApiLog::EppLog.create!({
|
||||
request: params[:frame],
|
||||
request_command: params[:command],
|
||||
request_successful: epp_errors.empty?,
|
||||
request_object: OBJECT_TYPES[params_hash['epp']['xmlns:ns2']],
|
||||
response: @response,
|
||||
api_user_name: current_epp_user.try(:to_s),
|
||||
api_user_registrar: current_epp_user.try(:registrar).try(:to_s)
|
||||
})
|
||||
end
|
||||
end
|
||||
|
|
|
@ -13,7 +13,8 @@ module Epp::PollHelper
|
|||
end
|
||||
|
||||
if @message.attached_obj_type == 'Keyrelay'
|
||||
render 'epp/poll/poll_keyrelay'
|
||||
@response = render_to_string('epp/poll/poll_keyrelay')
|
||||
render xml: @response
|
||||
else
|
||||
render 'epp/poll/poll_req'
|
||||
end
|
||||
|
|
6
app/models/api_log/db.rb
Normal file
6
app/models/api_log/db.rb
Normal file
|
@ -0,0 +1,6 @@
|
|||
module ApiLog
|
||||
class Db < ActiveRecord::Base
|
||||
self.abstract_class = true
|
||||
establish_connection "api_log_#{Rails.env}".to_sym
|
||||
end
|
||||
end
|
4
app/models/api_log/epp_log.rb
Normal file
4
app/models/api_log/epp_log.rb
Normal file
|
@ -0,0 +1,4 @@
|
|||
module ApiLog
|
||||
class EppLog < Db
|
||||
end
|
||||
end
|
4
app/models/api_log/repp_log.rb
Normal file
4
app/models/api_log/repp_log.rb
Normal file
|
@ -0,0 +1,4 @@
|
|||
module ApiLog
|
||||
class ReppLog < Db
|
||||
end
|
||||
end
|
36
db/migrate/20150109081914_create_api_log_tables.rb
Normal file
36
db/migrate/20150109081914_create_api_log_tables.rb
Normal file
|
@ -0,0 +1,36 @@
|
|||
class CreateApiLogTables < ActiveRecord::Migration
|
||||
def connection
|
||||
ApiLog::Db.connection
|
||||
end
|
||||
|
||||
def up
|
||||
create_table :epp_logs do |t|
|
||||
t.text :request
|
||||
t.text :response
|
||||
t.string :request_command
|
||||
t.string :request_object
|
||||
t.string :request_successful
|
||||
t.string :api_user_name
|
||||
t.string :api_user_registrar
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
|
||||
create_table :repp_logs do |t|
|
||||
t.text :request
|
||||
t.text :response
|
||||
t.string :request_command
|
||||
t.string :request_object
|
||||
t.string :request_successful
|
||||
t.string :api_user_name
|
||||
t.string :api_user_registrar
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
drop_table :epp_logs
|
||||
drop_table :repp_logs
|
||||
end
|
||||
end
|
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20150105134026) do
|
||||
ActiveRecord::Schema.define(version: 20150109081914) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue