Added xml epp console required endpoints and sample xml files

This commit is contained in:
Sergei Tsoganov 2022-11-23 12:41:00 +02:00
parent 30fd6d2465
commit aaa0e89cfe
21 changed files with 460 additions and 4 deletions

View file

@ -0,0 +1,57 @@
module EppRequestable
extend ActiveSupport::Concern
included do
before_action :validate_epp_user, only: :create
end
def create
result = server.request(request_params[:payload])
render_success(data: { xml: result })
rescue StandardError
handle_non_epp_errors(nil, I18n.t('errors.messages.epp_conn_error'))
end
private
def validate_epp_user
tag = current_user.username
password = current_user.plain_text_password
res = server.open_connection
unless Nokogiri::XML(res).css('greeting')
server.close_connection # just in case
handle_non_epp_errors(nil, I18n.t('errors.messages.failed_epp_conn'))
return
end
ex = EppXml::Session.new(cl_trid_prefix: tag)
xml = ex.login(clID: { value: tag }, pw: { value: password })
res = server.send_request(xml)
if Nokogiri::XML(res).css('result').first['code'] != '1000'
handle_non_epp_errors(nil, Nokogiri::XML(res).css('result').text)
end
server.close_connection
rescue OpenSSL::SSL::SSLError => e
Rails.logger.error "INVALID CERT: #{e}"
Rails.logger.error "INVALID CERT DEBUG INFO: epp_hostname: #{ENV['epp_hostname']}," \
"port: #{ENV['epp_port']}, cert_path: #{ENV['cert_path']}, key_path: #{ENV['key_path']}"
handle_non_epp_errors(nil, I18n.t('errors.messages.invalid_cert'))
end
def server
client_cert = File.read(ENV['cert_path'])
client_key = File.read(ENV['key_path'])
port = ENV['epp_port'] || 700
@server ||= Epp::Server.new({ server: ENV['epp_hostname'], tag: current_user.username,
password: current_user.plain_text_password,
port: port,
cert: OpenSSL::X509::Certificate.new(client_cert),
key: OpenSSL::PKey::RSA.new(client_key) })
end
def request_params
params.require(:xml_console).permit(:payload)
end
end

View file

@ -0,0 +1,55 @@
module Repp
module V1
module Registrar
class XmlConsoleController < BaseController
include EppRequestable
PREFS = %w[
domain-ee
contact-ee
eis
epp-ee
].freeze
def load_xml
cl_trid = "#{current_user.username}-#{Time.zone.now.to_i}"
xml_dir_path = Rails.root.join('app/views/epp/sample_requests').to_s
xml = File.read("#{xml_dir_path}/#{params[:obj]}/#{params[:epp_action]}.xml")
xml = prepare_payload(xml, cl_trid)
render_success(data: { xml: xml })
end
private
def prepare_payload(xml, cl_trid)
PREFS.map do |pref|
xml = load_schema_by_prefix(pref, xml)
end
xml.gsub!('<clTRID>ABC-12345</clTRID>', "<clTRID>#{cl_trid}</clTRID>")
xml
end
def load_schema_by_prefix(pref, xml)
case pref
when 'epp-ee'
insert_prefix_and_version(xml, pref, '1.0')
when 'eis'
insert_prefix_and_version(xml, pref, '1.0')
when 'contact-ee'
insert_prefix_and_version(xml, pref, '1.1')
else
insert_prefix_and_version(xml, pref, '1.2')
end
end
def insert_prefix_and_version(xml, pref, version)
xml.gsub!("\"#{pref}\"",
"\"#{Xsd::Schema.filename(for_prefix: pref.to_s, for_version: version)}\"")
xml
end
end
end
end
end

View file

@ -65,7 +65,6 @@ class Domain < ApplicationRecord
statuses.include? DomainStatus::SERVER_REGISTRANT_CHANGE_PROHIBITED
end
# NB! contacts, admin_contacts, tech_contacts are empty for a new record
has_many :domain_contacts, dependent: :destroy
has_many :contacts, through: :domain_contacts, source: :contact

View file

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="epp-ee">
<command>
<check>
<contact:check
xmlns:contact="contact-ee">
<contact:id>sh8013</contact:id>
</contact:check>
</check>
<clTRID>ABC-12345</clTRID>
</command>
</epp>

View file

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="epp-ee">
<command>
<check>
<contact:check
xmlns:contact="contact-ee">
<contact:id>sh8013</contact:id>
<contact:id>sh13</contact:id>
<contact:id>vsdfvq</contact:id>
</contact:check>
</check>
<clTRID>ABC-12345</clTRID>
</command>
</epp>

View file

@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="epp-ee">
<command>
<create>
<contact:create xmlns:contact="contact-ee">
<contact:postalInfo>
<contact:name>Sillius Soddus</contact:name>
<contact:addr>
<contact:street>123 Example Dr.</contact:street>
<contact:street>Suite 100</contact:street>
<contact:street/>
<contact:city>Megaton</contact:city>
<contact:sp>F3 </contact:sp>
<contact:pc>201-33</contact:pc>
<contact:cc>EE</contact:cc>
</contact:addr>
</contact:postalInfo>
<contact:voice>+372.1234567</contact:voice>
<contact:email>example@test.example</contact:email>
</contact:create>
</create>
<extension>
<eis:extdata xmlns:eis="eis">
<eis:ident type="org" cc="EE">123</eis:ident>
<eis:legalDocument type="pdf">
dGVzdCBmYWlsCg==
</eis:legalDocument>
</eis:extdata>
</extension>
<clTRID>ABC-12345</clTRID>
</command>
</epp>

View file

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="epp-ee">
<command>
<delete>
<contact:delete
xmlns:contact="contact-ee">
<contact:id>sh8013</contact:id>
<contact:authInfo>
<contact:pw>wrong-one</contact:pw>
</contact:authInfo>
</contact:delete>
</delete>
<extension>
<eis:extdata xmlns:eis="eis">
<eis:legalDocument type="pdf">
dGVzdCBmYWlsCg==
</eis:legalDocument>
</eis:extdata>
</extension>
<clTRID>ABC-12345</clTRID>
</command>
</epp>

View file

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="epp-ee">
<command>
<info>
<contact:info xmlns:contact="contact-ee">
<contact:id>sh8013</contact:id>
<contact:authInfo>
<contact:pw>Aas34fq</contact:pw>
</contact:authInfo>
</contact:info>
</info>
<clTRID>ABC-12345</clTRID>
</command>
</epp>

View file

@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="epp-ee">
<command>
<update>
<contact:update xmlns:contact="contact-ee">
<contact:id>sh8013</contact:id>
<contact:chg>
<contact:postalInfo>
<contact:name>John Doe</contact:name>
<contact:addr>
<contact:street>123 Example Dr.</contact:street>
<contact:street>Suite 100</contact:street>
<contact:city>Dulles</contact:city>
<contact:sp>VA</contact:sp>
<contact:pc>20166-6503</contact:pc>
<contact:cc>EE</contact:cc>
</contact:addr>
</contact:postalInfo>
<contact:voice>+123.7035555555</contact:voice>
<contact:email>jdoe@example.com</contact:email>
<contact:authInfo>
<contact:pw>2fooBAR</contact:pw>
</contact:authInfo>
</contact:chg>
</contact:update>
</update>
<extension>
<eis:extdata xmlns:eis="eis">
<eis:legalDocument type="pdf">
dGVzdCBmYWlsCg==
</eis:legalDocument>
</eis:extdata>
</extension>
<clTRID>ABC-12345</clTRID>
</command>
</epp>

View file

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="epp-ee">
<command>
<check>
<domain:check
xmlns:domain="domain-ee">
<domain:name>example.ee</domain:name>
</domain:check>
</check>
<clTRID>ABC-12345</clTRID>
</command>
</epp>

View file

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="epp-ee">
<command>
<update>
<domain:update
xmlns:domain="domain-ee">
<domain:name>example.ee</domain:name>
<domain:rem>
<domain:status s="clientHold"/>
</domain:rem>
</domain:update>
</update>
<clTRID>timo-1579351654</clTRID>
</command>
</epp>

View file

@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="epp-ee">
<command>
<create>
<domain:create
xmlns:domain="domain-ee">
<domain:name>example.ee</domain:name>
<domain:period unit="y">1</domain:period>
<domain:ns>
<domain:hostAttr>
<domain:hostName>ns1.example.net</domain:hostName>
</domain:hostAttr>
<domain:hostAttr>
<domain:hostName>ns2.example.net</domain:hostName>
<domain:hostAddr ip="v4">192.0.2.2</domain:hostAddr>
<domain:hostAddr ip="v6">1080:0:0:0:8:800:200C:417A</domain:hostAddr>
</domain:hostAttr>
</domain:ns>
<domain:registrant>jd1234</domain:registrant>
<domain:contact type="admin">sh8013</domain:contact>
<domain:contact type="tech">sh8013</domain:contact>
<domain:contact type="tech">sh801333</domain:contact>
</domain:create>
</create>
<extension>
<secDNS:create xmlns:secDNS="urn:ietf:params:xml:ns:secDNS-1.1">
<secDNS:keyData>
<secDNS:flags>257</secDNS:flags>
<secDNS:protocol>3</secDNS:protocol>
<secDNS:alg>8</secDNS:alg>
<secDNS:pubKey>AwEAAddt2AkLfYGKgiEZB5SmIF8EvrjxNMH6HtxWEA4RJ9Ao6LCWheg8</secDNS:pubKey>
</secDNS:keyData>
</secDNS:create>
<eis:extdata xmlns:eis="eis">
<eis:legalDocument type="pdf">
dGVzdCBmYWlsCg==
</eis:legalDocument>
</eis:extdata>
</extension>
<clTRID>ABC-12345</clTRID>
</command>
</epp>

View file

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="epp-ee">
<command>
<delete>
<domain:delete
xmlns:domain="domain-ee">
<domain:name>example.ee</domain:name>
</domain:delete>
</delete>
<extension>
<eis:extdata xmlns:eis="eis">
<eis:legalDocument type="pdf">
dGVzdCBmYWlsCg==
</eis:legalDocument>
</eis:extdata>
</extension>
<clTRID>ABC-12345</clTRID>
</command>
</epp>

View file

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="epp-ee">
<command>
<info>
<domain:info
xmlns:domain="domain-ee">
<domain:name hosts="all">example.ee</domain:name>
<domain:authInfo>
<domain:pw>2fooBAR</domain:pw>
</domain:authInfo>
</domain:info>
</info>
<clTRID>ABC-12345</clTRID>
</command>
</epp>

View file

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="epp-ee">
<command>
<renew>
<domain:renew
xmlns:domain="domain-ee">
<domain:name>example.ee</domain:name>
<domain:curExpDate>2014-08-07</domain:curExpDate>
<domain:period unit="y">1</domain:period>
</domain:renew>
</renew>
<clTRID>ABC-12345</clTRID>
</command>
</epp>

View file

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="epp-ee">
<command>
<transfer op="request">
<domain:transfer
xmlns:domain="domain-ee">
<domain:name>example.ee</domain:name>
<domain:authInfo>
<domain:pw roid="JD1234-REP">2BARfoo</domain:pw>
</domain:authInfo>
</domain:transfer>
</transfer>
<extension>
<eis:extdata xmlns:eis="eis">
<eis:legalDocument type="pdf">
dGVzdCBmYWlsCg==
</eis:legalDocument>
</eis:extdata>
</extension>
<clTRID>ABC-12345</clTRID>
</command>
</epp>

View file

@ -0,0 +1,54 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="epp-ee">
<command>
<update>
<domain:update
xmlns:domain="domain-ee">
<domain:name>example.ee</domain:name>
<domain:add>
<domain:ns>
<domain:hostAttr>
<domain:hostName>ns1.example.com</domain:hostName>
</domain:hostAttr>
<domain:hostAttr>
<domain:hostName>ns2.example.com</domain:hostName>
</domain:hostAttr>
</domain:ns>
<domain:contact type="tech">mak21</domain:contact>
</domain:add>
<domain:rem>
<domain:ns>
<domain:hostAttr>
<domain:hostName>ns1.example.net</domain:hostName>
</domain:hostAttr>
</domain:ns>
<domain:contact type="tech">mak21</domain:contact>
</domain:rem>
<domain:chg>
<domain:registrant>mak21</domain:registrant>
<domain:authInfo>
<domain:pw>newpw</domain:pw>
</domain:authInfo>
</domain:chg>
</domain:update>
</update>
<extension>
<secDNS:update xmlns:secDNS="urn:ietf:params:xml:ns:secDNS-1.1">
<secDNS:rem>
<secDNS:keyData>
<secDNS:flags>257</secDNS:flags>
<secDNS:protocol>3</secDNS:protocol>
<secDNS:alg>8</secDNS:alg>
<secDNS:pubKey>700b97b591ed27ec2590d19f06f88bba700b97b591ed27ec2590d19f</secDNS:pubKey>
</secDNS:keyData>
</secDNS:rem>
</secDNS:update>
<eis:extdata xmlns:eis="eis">
<eis:legalDocument type="pdf">
dGVzdCBmYWlsCg==
</eis:legalDocument>
</eis:extdata>
</extension>
<clTRID>ABC-12345</clTRID>
</command>
</epp>

View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
<command>
<poll op="req"/>
<clTRID>ABC-12345</clTRID>
</command>
</epp>

View file

@ -61,6 +61,13 @@ contact_org_enabled: 'false'
# System default for legal document types is: pdf,asice,sce,asics,scs,adoc,edoc,bdoc,ddoc,zip,rar,gz,tar,7z,odt,doc,docx
# legal_document_types: "pdf,asice,sce,asics,scs,adoc,edoc,bdoc,ddoc,zip,rar,gz,tar,7z,odt,doc,docx"
#
# REGISTRAR configuration
#
epp_port: '700'
cert_path: '/opt/ca/certs/webclient.crt.pem'
key_path: '/opt/ca/private/webclient.key.pem'
epp_hostname: 'epp_proxy'
repp_url: 'http://epp:3000/repp/v1/'
# Estonian Company Register

View file

@ -187,6 +187,9 @@ en:
required_ident_attribute_missing: "Required ident attribute missing: %{key}"
invalid_iso31661_alpha2: does not conform to ISO 3166-1 alpha-2 standard
invalid_iso8601_date: has invalid date format YYYY-MM-DD (ISO 8601)
invalid_cert: 'Invalid certificate'
failed_epp_conn: 'Failed to open connection to EPP server!'
epp_conn_error: 'CONNECTION ERROR - Is the EPP server running?'
code: 'Code'
action: 'Action'

View file

@ -106,7 +106,7 @@ Rails.application.routes.draw do
end
end
namespace :registrar do
resources :notifications, only: [:index, :show, :update] do
resources :notifications, only: %i[index show update] do
collection do
get '/all_notifications', to: 'notifications#all_notifications'
end
@ -128,6 +128,11 @@ Rails.application.routes.draw do
post '/tara_callback', to: 'auth#tara_callback'
end
end
resource :xml_console, controller: 'xml_console', only: %i[create] do
collection do
get 'load_xml'
end
end
end
resources :domains, constraints: { id: /.*/ } do
resources :nameservers, only: %i[index create destroy], constraints: { id: /.*/ }, controller: 'domains/nameservers'
@ -136,8 +141,8 @@ Rails.application.routes.draw do
resources :renew, only: %i[create], constraints: { id: /.*/ }, controller: 'domains/renews'
resources :transfer, only: %i[create], constraints: { id: /.*/ }, controller: 'domains/transfers'
resources :statuses, only: %i[update destroy], constraints: { id: /.*/ }, controller: 'domains/statuses'
match "dnssec", to: "domains/dnssec#destroy", via: "delete", defaults: { id: nil }
match "contacts", to: "domains/contacts#destroy", via: "delete", defaults: { id: nil }
match 'dnssec', to: 'domains/dnssec#destroy', via: 'delete', defaults: { id: nil }
match 'contacts', to: 'domains/contacts#destroy', via: 'delete', defaults: { id: nil }
collection do
get ':id/transfer_info', to: 'domains#transfer_info', constraints: { id: /.*/ }
post 'transfer', to: 'domains#transfer'