mirror of
https://github.com/internetee/registry.git
synced 2025-05-16 17:37:17 +02:00
Validate request against schemas #2799
This commit is contained in:
parent
c1f9a470df
commit
c79fee5a49
2 changed files with 18 additions and 13 deletions
|
@ -6,22 +6,26 @@ class EppController < ApplicationController
|
|||
|
||||
before_action :generate_svtrid
|
||||
before_action :latin_only
|
||||
# before_action :validate_against_schema
|
||||
before_action :validate_against_schema
|
||||
|
||||
# def validate_against_schema
|
||||
# if params[:epp_object_type] == :domain
|
||||
def validate_against_schema
|
||||
# filename =
|
||||
# if params[:epp_object_type] == :domain
|
||||
|
||||
# xsd = Nokogiri::XML::Schema(File.read('doc/schemas/domain-eis-1.0.xsd'))
|
||||
# xsd.validate(Nokogiri::XML(params[:raw_frame])).each do |error|
|
||||
# epp_errors << {
|
||||
# code: 2002,
|
||||
# msg: error
|
||||
# }
|
||||
# end
|
||||
# end
|
||||
return if params[:action] == 'hello'
|
||||
params[:schema] = 'epp-1.0.xsd' unless params[:schema]
|
||||
|
||||
# handle_errors and return if epp_errors.any?
|
||||
# end
|
||||
xsd = Nokogiri::XML::Schema(File.read("doc/schemas/#{params[:schema]}"))
|
||||
xsd.validate(Nokogiri::XML(params[:raw_frame])).each do |error|
|
||||
epp_errors << {
|
||||
code: 2001,
|
||||
msg: error
|
||||
}
|
||||
end
|
||||
|
||||
# end
|
||||
handle_errors and return if epp_errors.any?
|
||||
end
|
||||
|
||||
before_action :validate_request
|
||||
before_action :update_epp_session
|
||||
|
|
|
@ -15,6 +15,7 @@ class EppConstraint
|
|||
unless [:keyrelay, :poll].include?(@type)
|
||||
element = "//#{@type}:#{request.params[:action]}"
|
||||
return false if parsed_frame.xpath("#{element}", OBJECT_TYPES[@type]).none?
|
||||
request.params[:schema] = OBJECT_TYPES[@type][@type].split('/').last
|
||||
end
|
||||
|
||||
request.params[:parsed_frame] = parsed_frame.remove_namespaces!
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue