mirror of
https://github.com/internetee/registry.git
synced 2025-05-17 17:59:47 +02:00
Domain xsd + enable validation
This commit is contained in:
parent
48710b41f7
commit
1f468352c8
3 changed files with 449 additions and 13 deletions
|
@ -1,6 +1,11 @@
|
||||||
module Epp::Common
|
module Epp::Common
|
||||||
extend ActiveSupport::Concern
|
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
|
included do
|
||||||
protect_from_forgery with: :null_session
|
protect_from_forgery with: :null_session
|
||||||
before_action :validate_request, only: [:proxy]
|
before_action :validate_request, only: [:proxy]
|
||||||
|
@ -24,13 +29,17 @@ module Epp::Common
|
||||||
end
|
end
|
||||||
|
|
||||||
def validate_request
|
def validate_request
|
||||||
# xsd = Nokogiri::XML::Schema(File.read('doc/schemas/contact-1.0.xsd'))
|
type = OBJECT_TYPES[params_hash['epp']['xmlns:ns2']]
|
||||||
# doc = Nokogiri::XML(params[:frame])
|
return unless type
|
||||||
# @extValues = xsd.validate(doc)
|
|
||||||
# if @extValues.any?
|
xsd = Nokogiri::XML::Schema(File.read("doc/schemas/#{type}-1.0.xsd"))
|
||||||
# @code = '2001'
|
doc = Nokogiri::XML(params[:frame])
|
||||||
# @msg = 'Command syntax error'
|
@extValues = xsd.validate(doc)
|
||||||
# render '/epp/error' and return
|
if @extValues.any?
|
||||||
# end
|
binding.pry
|
||||||
|
@code = '2001'
|
||||||
|
@msg = 'Command syntax error'
|
||||||
|
render '/epp/error' and return
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,11 +3,6 @@ class Epp::CommandsController < ApplicationController
|
||||||
include Epp::DomainsHelper
|
include Epp::DomainsHelper
|
||||||
include Epp::ContactsHelper
|
include Epp::ContactsHelper
|
||||||
|
|
||||||
OBJECT_TYPES = {
|
|
||||||
'urn:ietf:params:xml:ns:contact-1.0' => 'contact',
|
|
||||||
'urn:ietf:params:xml:ns:domain-1.0' => 'domain'
|
|
||||||
}
|
|
||||||
|
|
||||||
private
|
private
|
||||||
def create
|
def create
|
||||||
send("create_#{OBJECT_TYPES[params_hash['epp']['xmlns:ns2']]}")
|
send("create_#{OBJECT_TYPES[params_hash['epp']['xmlns:ns2']]}")
|
||||||
|
|
432
doc/schemas/domain-1.0.xsd
Normal file
432
doc/schemas/domain-1.0.xsd
Normal file
|
@ -0,0 +1,432 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
<schema targetNamespace="urn:ietf:params:xml:ns:domain-1.0"
|
||||||
|
xmlns:domain="urn:ietf:params:xml:ns:domain-1.0"
|
||||||
|
xmlns:host="urn:ietf:params:xml:ns:host-1.0"
|
||||||
|
xmlns:epp="urn:ietf:params:xml:ns:epp-1.0"
|
||||||
|
xmlns:eppcom="urn:ietf:params:xml:ns:eppcom-1.0"
|
||||||
|
xmlns="http://www.w3.org/2001/XMLSchema"
|
||||||
|
elementFormDefault="qualified">
|
||||||
|
|
||||||
|
<!--
|
||||||
|
Import common element types.
|
||||||
|
-->
|
||||||
|
<import namespace="urn:ietf:params:xml:ns:eppcom-1.0"/>
|
||||||
|
<import namespace="urn:ietf:params:xml:ns:epp-1.0"/>
|
||||||
|
<import namespace="urn:ietf:params:xml:ns:host-1.0"/>
|
||||||
|
|
||||||
|
<annotation>
|
||||||
|
<documentation>
|
||||||
|
Extensible Provisioning Protocol v1.0
|
||||||
|
domain provisioning schema.
|
||||||
|
</documentation>
|
||||||
|
</annotation>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
Child elements found in EPP commands.
|
||||||
|
-->
|
||||||
|
<element name="check" type="domain:mNameType"/>
|
||||||
|
<element name="create" type="domain:createType"/>
|
||||||
|
<element name="delete" type="domain:sNameType"/>
|
||||||
|
<element name="info" type="domain:infoType"/>
|
||||||
|
<element name="renew" type="domain:renewType"/>
|
||||||
|
<element name="transfer" type="domain:transferType"/>
|
||||||
|
<element name="update" type="domain:updateType"/>
|
||||||
|
<!--
|
||||||
|
Child elements of the <create> command.
|
||||||
|
-->
|
||||||
|
<complexType name="createType">
|
||||||
|
<sequence>
|
||||||
|
<element name="name" type="eppcom:labelType"/>
|
||||||
|
<element name="period" type="domain:periodType"
|
||||||
|
minOccurs="0"/>
|
||||||
|
<element name="ns" type="domain:nsType"
|
||||||
|
minOccurs="0"/>
|
||||||
|
<element name="registrant" type="eppcom:clIDType"
|
||||||
|
minOccurs="0"/>
|
||||||
|
<element name="contact" type="domain:contactType"
|
||||||
|
minOccurs="0" maxOccurs="unbounded"/>
|
||||||
|
<element name="authInfo" type="domain:authInfoType"/>
|
||||||
|
</sequence>
|
||||||
|
</complexType>
|
||||||
|
|
||||||
|
<complexType name="periodType">
|
||||||
|
<simpleContent>
|
||||||
|
<extension base="domain:pLimitType">
|
||||||
|
<attribute name="unit" type="domain:pUnitType"
|
||||||
|
use="required"/>
|
||||||
|
</extension>
|
||||||
|
</simpleContent>
|
||||||
|
</complexType>
|
||||||
|
|
||||||
|
<simpleType name="pLimitType">
|
||||||
|
<restriction base="unsignedShort">
|
||||||
|
<minInclusive value="1"/>
|
||||||
|
<maxInclusive value="99"/>
|
||||||
|
</restriction>
|
||||||
|
</simpleType>
|
||||||
|
|
||||||
|
<simpleType name="pUnitType">
|
||||||
|
<restriction base="token">
|
||||||
|
<enumeration value="y"/>
|
||||||
|
<enumeration value="m"/>
|
||||||
|
</restriction>
|
||||||
|
</simpleType>
|
||||||
|
|
||||||
|
<complexType name="nsType">
|
||||||
|
<choice>
|
||||||
|
<element name="hostObj" type="eppcom:labelType"
|
||||||
|
maxOccurs="unbounded"/>
|
||||||
|
<element name="hostAttr" type="domain:hostAttrType"
|
||||||
|
maxOccurs="unbounded"/>
|
||||||
|
</choice>
|
||||||
|
</complexType>
|
||||||
|
<!--
|
||||||
|
Name servers are either host objects or attributes.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<complexType name="hostAttrType">
|
||||||
|
<sequence>
|
||||||
|
<element name="hostName" type="eppcom:labelType"/>
|
||||||
|
<element name="hostAddr" type="host:addrType"
|
||||||
|
|
||||||
|
minOccurs="0" maxOccurs="unbounded"/>
|
||||||
|
</sequence>
|
||||||
|
</complexType>
|
||||||
|
<!--
|
||||||
|
If attributes, addresses are optional and follow the
|
||||||
|
structure defined in the host mapping.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<complexType name="contactType">
|
||||||
|
<simpleContent>
|
||||||
|
<extension base="eppcom:clIDType">
|
||||||
|
<attribute name="type" type="domain:contactAttrType"/>
|
||||||
|
</extension>
|
||||||
|
</simpleContent>
|
||||||
|
</complexType>
|
||||||
|
|
||||||
|
<simpleType name="contactAttrType">
|
||||||
|
<restriction base="token">
|
||||||
|
<enumeration value="admin"/>
|
||||||
|
<enumeration value="billing"/>
|
||||||
|
<enumeration value="tech"/>
|
||||||
|
</restriction>
|
||||||
|
</simpleType>
|
||||||
|
|
||||||
|
<complexType name="authInfoType">
|
||||||
|
<choice>
|
||||||
|
<element name="pw" type="eppcom:pwAuthInfoType"/>
|
||||||
|
<element name="ext" type="eppcom:extAuthInfoType"/>
|
||||||
|
</choice>
|
||||||
|
</complexType>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
Child element of commands that require a single name.
|
||||||
|
-->
|
||||||
|
<complexType name="sNameType">
|
||||||
|
<sequence>
|
||||||
|
<element name="name" type="eppcom:labelType"/>
|
||||||
|
</sequence>
|
||||||
|
</complexType>
|
||||||
|
<!--
|
||||||
|
Child element of commands that accept multiple names.
|
||||||
|
-->
|
||||||
|
<complexType name="mNameType">
|
||||||
|
<sequence>
|
||||||
|
<element name="name" type="eppcom:labelType"
|
||||||
|
maxOccurs="unbounded"/>
|
||||||
|
</sequence>
|
||||||
|
</complexType>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
Child elements of the <info> command.
|
||||||
|
-->
|
||||||
|
<complexType name="infoType">
|
||||||
|
<sequence>
|
||||||
|
<element name="name" type="domain:infoNameType"/>
|
||||||
|
<element name="authInfo" type="domain:authInfoType"
|
||||||
|
minOccurs="0"/>
|
||||||
|
</sequence>
|
||||||
|
</complexType>
|
||||||
|
|
||||||
|
<complexType name="infoNameType">
|
||||||
|
<simpleContent>
|
||||||
|
<extension base = "eppcom:labelType">
|
||||||
|
<attribute name="hosts" type="domain:hostsType"
|
||||||
|
default="all"/>
|
||||||
|
</extension>
|
||||||
|
</simpleContent>
|
||||||
|
</complexType>
|
||||||
|
|
||||||
|
<simpleType name="hostsType">
|
||||||
|
<restriction base="token">
|
||||||
|
<enumeration value="all"/>
|
||||||
|
<enumeration value="del"/>
|
||||||
|
<enumeration value="none"/>
|
||||||
|
<enumeration value="sub"/>
|
||||||
|
</restriction>
|
||||||
|
</simpleType>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
Child elements of the <renew> command.
|
||||||
|
-->
|
||||||
|
<complexType name="renewType">
|
||||||
|
<sequence>
|
||||||
|
<element name="name" type="eppcom:labelType"/>
|
||||||
|
<element name="curExpDate" type="date"/>
|
||||||
|
<element name="period" type="domain:periodType"
|
||||||
|
minOccurs="0"/>
|
||||||
|
</sequence>
|
||||||
|
</complexType>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
Child elements of the <transfer> command.
|
||||||
|
-->
|
||||||
|
<complexType name="transferType">
|
||||||
|
<sequence>
|
||||||
|
<element name="name" type="eppcom:labelType"/>
|
||||||
|
<element name="period" type="domain:periodType"
|
||||||
|
minOccurs="0"/>
|
||||||
|
<element name="authInfo" type="domain:authInfoType"
|
||||||
|
minOccurs="0"/>
|
||||||
|
</sequence>
|
||||||
|
</complexType>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
Child elements of the <update> command.
|
||||||
|
-->
|
||||||
|
<complexType name="updateType">
|
||||||
|
<sequence>
|
||||||
|
<element name="name" type="eppcom:labelType"/>
|
||||||
|
<element name="add" type="domain:addRemType"
|
||||||
|
minOccurs="0"/>
|
||||||
|
<element name="rem" type="domain:addRemType"
|
||||||
|
minOccurs="0"/>
|
||||||
|
<element name="chg" type="domain:chgType"
|
||||||
|
minOccurs="0"/>
|
||||||
|
</sequence>
|
||||||
|
</complexType>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
Data elements that can be added or removed.
|
||||||
|
-->
|
||||||
|
<complexType name="addRemType">
|
||||||
|
<sequence>
|
||||||
|
<element name="ns" type="domain:nsType"
|
||||||
|
minOccurs="0"/>
|
||||||
|
<element name="contact" type="domain:contactType"
|
||||||
|
minOccurs="0" maxOccurs="unbounded"/>
|
||||||
|
<element name="status" type="domain:statusType"
|
||||||
|
minOccurs="0" maxOccurs="11"/>
|
||||||
|
</sequence>
|
||||||
|
</complexType>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
Data elements that can be changed.
|
||||||
|
-->
|
||||||
|
<complexType name="chgType">
|
||||||
|
<sequence>
|
||||||
|
<element name="registrant" type="domain:clIDChgType"
|
||||||
|
minOccurs="0"/>
|
||||||
|
<element name="authInfo" type="domain:authInfoChgType"
|
||||||
|
minOccurs="0"/>
|
||||||
|
</sequence>
|
||||||
|
</complexType>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
Allow the registrant value to be nullified by changing the
|
||||||
|
minLength restriction to "0".
|
||||||
|
-->
|
||||||
|
<simpleType name="clIDChgType">
|
||||||
|
<restriction base="token">
|
||||||
|
<minLength value="0"/>
|
||||||
|
<maxLength value="16"/>
|
||||||
|
</restriction>
|
||||||
|
</simpleType>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
Allow the authInfo value to be nullified by including an
|
||||||
|
empty element within the choice.
|
||||||
|
-->
|
||||||
|
<complexType name="authInfoChgType">
|
||||||
|
<choice>
|
||||||
|
<element name="pw" type="eppcom:pwAuthInfoType"/>
|
||||||
|
<element name="ext" type="eppcom:extAuthInfoType"/>
|
||||||
|
<element name="null"/>
|
||||||
|
</choice>
|
||||||
|
</complexType>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
Child response elements.
|
||||||
|
-->
|
||||||
|
<element name="chkData" type="domain:chkDataType"/>
|
||||||
|
<element name="creData" type="domain:creDataType"/>
|
||||||
|
<element name="infData" type="domain:infDataType"/>
|
||||||
|
<element name="panData" type="domain:panDataType"/>
|
||||||
|
<element name="renData" type="domain:renDataType"/>
|
||||||
|
<element name="trnData" type="domain:trnDataType"/>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
<check> response elements.
|
||||||
|
-->
|
||||||
|
<complexType name="chkDataType">
|
||||||
|
<sequence>
|
||||||
|
<element name="cd" type="domain:checkType"
|
||||||
|
maxOccurs="unbounded"/>
|
||||||
|
</sequence>
|
||||||
|
</complexType>
|
||||||
|
|
||||||
|
<complexType name="checkType">
|
||||||
|
<sequence>
|
||||||
|
<element name="name" type="domain:checkNameType"/>
|
||||||
|
<element name="reason" type="eppcom:reasonType"
|
||||||
|
minOccurs="0"/>
|
||||||
|
</sequence>
|
||||||
|
</complexType>
|
||||||
|
|
||||||
|
<complexType name="checkNameType">
|
||||||
|
<simpleContent>
|
||||||
|
<extension base="eppcom:labelType">
|
||||||
|
<attribute name="avail" type="boolean"
|
||||||
|
use="required"/>
|
||||||
|
</extension>
|
||||||
|
</simpleContent>
|
||||||
|
</complexType>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
<create> response elements.
|
||||||
|
-->
|
||||||
|
<complexType name="creDataType">
|
||||||
|
<sequence>
|
||||||
|
<element name="name" type="eppcom:labelType"/>
|
||||||
|
<element name="crDate" type="dateTime"/>
|
||||||
|
<element name="exDate" type="dateTime"
|
||||||
|
minOccurs="0"/>
|
||||||
|
</sequence>
|
||||||
|
</complexType>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
<info> response elements.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<complexType name="infDataType">
|
||||||
|
<sequence>
|
||||||
|
<element name="name" type="eppcom:labelType"/>
|
||||||
|
<element name="roid" type="eppcom:roidType"/>
|
||||||
|
<element name="status" type="domain:statusType"
|
||||||
|
minOccurs="0" maxOccurs="11"/>
|
||||||
|
<element name="registrant" type="eppcom:clIDType"
|
||||||
|
minOccurs="0"/>
|
||||||
|
<element name="contact" type="domain:contactType"
|
||||||
|
minOccurs="0" maxOccurs="unbounded"/>
|
||||||
|
<element name="ns" type="domain:nsType"
|
||||||
|
minOccurs="0"/>
|
||||||
|
<element name="host" type="eppcom:labelType"
|
||||||
|
minOccurs="0" maxOccurs="unbounded"/>
|
||||||
|
<element name="clID" type="eppcom:clIDType"/>
|
||||||
|
<element name="crID" type="eppcom:clIDType"
|
||||||
|
minOccurs="0"/>
|
||||||
|
<element name="crDate" type="dateTime"
|
||||||
|
minOccurs="0"/>
|
||||||
|
<element name="upID" type="eppcom:clIDType"
|
||||||
|
minOccurs="0"/>
|
||||||
|
<element name="upDate" type="dateTime"
|
||||||
|
minOccurs="0"/>
|
||||||
|
<element name="exDate" type="dateTime"
|
||||||
|
minOccurs="0"/>
|
||||||
|
<element name="trDate" type="dateTime"
|
||||||
|
minOccurs="0"/>
|
||||||
|
<element name="authInfo" type="domain:authInfoType"
|
||||||
|
minOccurs="0"/>
|
||||||
|
</sequence>
|
||||||
|
</complexType>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
Status is a combination of attributes and an optional
|
||||||
|
human-readable message that may be expressed in languages other
|
||||||
|
than English.
|
||||||
|
-->
|
||||||
|
<complexType name="statusType">
|
||||||
|
<simpleContent>
|
||||||
|
<extension base="normalizedString">
|
||||||
|
<attribute name="s" type="domain:statusValueType"
|
||||||
|
use="required"/>
|
||||||
|
<attribute name="lang" type="language"
|
||||||
|
default="en"/>
|
||||||
|
</extension>
|
||||||
|
</simpleContent>
|
||||||
|
</complexType>
|
||||||
|
|
||||||
|
<simpleType name="statusValueType">
|
||||||
|
<restriction base="token">
|
||||||
|
<enumeration value="clientDeleteProhibited"/>
|
||||||
|
<enumeration value="clientHold"/>
|
||||||
|
<enumeration value="clientRenewProhibited"/>
|
||||||
|
<enumeration value="clientTransferProhibited"/>
|
||||||
|
<enumeration value="clientUpdateProhibited"/>
|
||||||
|
<enumeration value="inactive"/>
|
||||||
|
<enumeration value="ok"/>
|
||||||
|
<enumeration value="pendingCreate"/>
|
||||||
|
<enumeration value="pendingDelete"/>
|
||||||
|
<enumeration value="pendingRenew"/>
|
||||||
|
<enumeration value="pendingTransfer"/>
|
||||||
|
<enumeration value="pendingUpdate"/>
|
||||||
|
<enumeration value="serverDeleteProhibited"/>
|
||||||
|
<enumeration value="serverHold"/>
|
||||||
|
<enumeration value="serverRenewProhibited"/>
|
||||||
|
<enumeration value="serverTransferProhibited"/>
|
||||||
|
<enumeration value="serverUpdateProhibited"/>
|
||||||
|
</restriction>
|
||||||
|
</simpleType>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
Pending action notification response elements.
|
||||||
|
-->
|
||||||
|
<complexType name="panDataType">
|
||||||
|
<sequence>
|
||||||
|
<element name="name" type="domain:paNameType"/>
|
||||||
|
<element name="paTRID" type="epp:trIDType"/>
|
||||||
|
<element name="paDate" type="dateTime"/>
|
||||||
|
</sequence>
|
||||||
|
</complexType>
|
||||||
|
|
||||||
|
<complexType name="paNameType">
|
||||||
|
<simpleContent>
|
||||||
|
<extension base="eppcom:labelType">
|
||||||
|
<attribute name="paResult" type="boolean"
|
||||||
|
use="required"/>
|
||||||
|
</extension>
|
||||||
|
</simpleContent>
|
||||||
|
</complexType>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
<renew> response elements.
|
||||||
|
-->
|
||||||
|
<complexType name="renDataType">
|
||||||
|
<sequence>
|
||||||
|
<element name="name" type="eppcom:labelType"/>
|
||||||
|
<element name="exDate" type="dateTime"
|
||||||
|
minOccurs="0"/>
|
||||||
|
</sequence>
|
||||||
|
</complexType>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
<transfer> response elements.
|
||||||
|
-->
|
||||||
|
<complexType name="trnDataType">
|
||||||
|
<sequence>
|
||||||
|
<element name="name" type="eppcom:labelType"/>
|
||||||
|
<element name="trStatus" type="eppcom:trStatusType"/>
|
||||||
|
<element name="reID" type="eppcom:clIDType"/>
|
||||||
|
<element name="reDate" type="dateTime"/>
|
||||||
|
<element name="acID" type="eppcom:clIDType"/>
|
||||||
|
<element name="acDate" type="dateTime"/>
|
||||||
|
<element name="exDate" type="dateTime"
|
||||||
|
minOccurs="0"/>
|
||||||
|
</sequence>
|
||||||
|
</complexType>
|
||||||
|
<!--
|
||||||
|
End of schema.
|
||||||
|
-->
|
||||||
|
</schema>
|
Loading…
Add table
Add a link
Reference in a new issue