diff --git a/app/controllers/concerns/epp/common.rb b/app/controllers/concerns/epp/common.rb index ea217a7ce..3038e0d7a 100644 --- a/app/controllers/concerns/epp/common.rb +++ b/app/controllers/concerns/epp/common.rb @@ -1,6 +1,11 @@ module Epp::Common extend ActiveSupport::Concern + OBJECT_TYPES = { + 'urn:ietf:params:xml:ns:contact-1.0' => 'contact', + 'urn:ietf:params:xml:ns:domain-1.0' => 'domain' + } + included do protect_from_forgery with: :null_session before_action :validate_request, only: [:proxy] @@ -24,13 +29,17 @@ module Epp::Common end def validate_request - # xsd = Nokogiri::XML::Schema(File.read('doc/schemas/contact-1.0.xsd')) - # doc = Nokogiri::XML(params[:frame]) - # @extValues = xsd.validate(doc) - # if @extValues.any? - # @code = '2001' - # @msg = 'Command syntax error' - # render '/epp/error' and return - # end + type = OBJECT_TYPES[params_hash['epp']['xmlns:ns2']] + return unless type + + xsd = Nokogiri::XML::Schema(File.read("doc/schemas/#{type}-1.0.xsd")) + doc = Nokogiri::XML(params[:frame]) + @extValues = xsd.validate(doc) + if @extValues.any? + binding.pry + @code = '2001' + @msg = 'Command syntax error' + render '/epp/error' and return + end end end diff --git a/app/controllers/epp/commands_controller.rb b/app/controllers/epp/commands_controller.rb index 602950a3d..fe2b0d054 100644 --- a/app/controllers/epp/commands_controller.rb +++ b/app/controllers/epp/commands_controller.rb @@ -3,11 +3,6 @@ class Epp::CommandsController < ApplicationController include Epp::DomainsHelper include Epp::ContactsHelper - OBJECT_TYPES = { - 'urn:ietf:params:xml:ns:contact-1.0' => 'contact', - 'urn:ietf:params:xml:ns:domain-1.0' => 'domain' - } - private def create send("create_#{OBJECT_TYPES[params_hash['epp']['xmlns:ns2']]}") diff --git a/doc/schemas/domain-1.0.xsd b/doc/schemas/domain-1.0.xsd new file mode 100644 index 000000000..d58e45c8c --- /dev/null +++ b/doc/schemas/domain-1.0.xsd @@ -0,0 +1,432 @@ + + + + + + + + + + + + Extensible Provisioning Protocol v1.0 + domain provisioning schema. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +