mirror of
https://github.com/internetee/registry.git
synced 2025-05-17 09:57:23 +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 :generate_svtrid
|
||||||
before_action :latin_only
|
before_action :latin_only
|
||||||
# before_action :validate_against_schema
|
before_action :validate_against_schema
|
||||||
|
|
||||||
# def validate_against_schema
|
def validate_against_schema
|
||||||
|
# filename =
|
||||||
# if params[:epp_object_type] == :domain
|
# if params[:epp_object_type] == :domain
|
||||||
|
|
||||||
# xsd = Nokogiri::XML::Schema(File.read('doc/schemas/domain-eis-1.0.xsd'))
|
return if params[:action] == 'hello'
|
||||||
# xsd.validate(Nokogiri::XML(params[:raw_frame])).each do |error|
|
params[:schema] = 'epp-1.0.xsd' unless params[:schema]
|
||||||
# epp_errors << {
|
|
||||||
# code: 2002,
|
xsd = Nokogiri::XML::Schema(File.read("doc/schemas/#{params[:schema]}"))
|
||||||
# msg: error
|
xsd.validate(Nokogiri::XML(params[:raw_frame])).each do |error|
|
||||||
# }
|
epp_errors << {
|
||||||
# end
|
code: 2001,
|
||||||
# end
|
msg: error
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
# handle_errors and return if epp_errors.any?
|
|
||||||
# end
|
# end
|
||||||
|
handle_errors and return if epp_errors.any?
|
||||||
|
end
|
||||||
|
|
||||||
before_action :validate_request
|
before_action :validate_request
|
||||||
before_action :update_epp_session
|
before_action :update_epp_session
|
||||||
|
|
|
@ -15,6 +15,7 @@ class EppConstraint
|
||||||
unless [:keyrelay, :poll].include?(@type)
|
unless [:keyrelay, :poll].include?(@type)
|
||||||
element = "//#{@type}:#{request.params[:action]}"
|
element = "//#{@type}:#{request.params[:action]}"
|
||||||
return false if parsed_frame.xpath("#{element}", OBJECT_TYPES[@type]).none?
|
return false if parsed_frame.xpath("#{element}", OBJECT_TYPES[@type]).none?
|
||||||
|
request.params[:schema] = OBJECT_TYPES[@type][@type].split('/').last
|
||||||
end
|
end
|
||||||
|
|
||||||
request.params[:parsed_frame] = parsed_frame.remove_namespaces!
|
request.params[:parsed_frame] = parsed_frame.remove_namespaces!
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue