mirror of
https://github.com/internetee/registry.git
synced 2025-06-12 15:44:45 +02:00
Fix BL after master emrge
This commit is contained in:
parent
43e5b74668
commit
c5e2ebe15e
5 changed files with 24 additions and 30 deletions
|
@ -214,8 +214,11 @@ module Repp
|
||||||
end
|
end
|
||||||
|
|
||||||
def domain_create_params
|
def domain_create_params
|
||||||
params.require(:domain).require(%i[name registrant_id period period_unit])
|
params.require(:domain).permit(:name, :registrant_id, :period, :period_unit, :registrar_id,
|
||||||
params.require(:domain).permit(%i[name registrant_id period period_unit registrar_id])
|
dnskeys_attributes: [%i[flags alg protocol public_key]],
|
||||||
|
nameservers_attributes: [[:hostname, ipv4: [], ipv6: []]],
|
||||||
|
admin_domain_contacts_attributes: [],
|
||||||
|
tech_domain_contacts_attributes: [])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -74,18 +74,13 @@ module Actions
|
||||||
def assign_dnskeys
|
def assign_dnskeys
|
||||||
return unless params[:dnskeys_attributes]&.any?
|
return unless params[:dnskeys_attributes]&.any?
|
||||||
|
|
||||||
params[:dnskeys_attributes].each { |dk| verify_public_key_integrity(dk) }
|
params[:dnskeys_attributes].each { |dk| verify_public_key_integrity(dk[:public_key]) }
|
||||||
params.dnskeys_attributes = params[:dnskeys_attributes]
|
domain.dnskeys_attributes = params[:dnskeys_attributes]
|
||||||
end
|
end
|
||||||
|
|
||||||
def verify_public_key_integrity(dnssec)
|
def verify_public_key_integrity(pub)
|
||||||
return if dnssec[:public_key].blank?
|
return if Dnskey.pub_key_base64?(pub)
|
||||||
|
|
||||||
value = dnssec[:public_key]
|
|
||||||
if !value.is_a?(String) || Base64.strict_encode64(Base64.strict_decode64(value)) != value
|
|
||||||
domain.add_epp_error(2005, nil, nil, %i[dnskeys invalid])
|
|
||||||
end
|
|
||||||
rescue ArgumentError
|
|
||||||
domain.add_epp_error(2005, nil, nil, %i[dnskeys invalid])
|
domain.add_epp_error(2005, nil, nil, %i[dnskeys invalid])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ module Actions
|
||||||
assign_new_registrant if params[:registrant]
|
assign_new_registrant if params[:registrant]
|
||||||
assign_relational_modifications
|
assign_relational_modifications
|
||||||
assign_requested_statuses
|
assign_requested_statuses
|
||||||
maybe_attach_legal_doc
|
Actions::BaseAction.maybe_attach_legal_doc(domain, params[:legal_document])
|
||||||
|
|
||||||
commit
|
commit
|
||||||
end
|
end
|
||||||
|
@ -98,7 +98,7 @@ module Actions
|
||||||
domain.add_epp_error('2306', nil, nil, %i[dnskeys ds_data_not_allowed])
|
domain.add_epp_error('2306', nil, nil, %i[dnskeys ds_data_not_allowed])
|
||||||
end
|
end
|
||||||
|
|
||||||
verify_public_key_integrity(key)
|
verify_public_key_integrity(key[:public_key])
|
||||||
|
|
||||||
@dnskeys << key.except(:action)
|
@dnskeys << key.except(:action)
|
||||||
end
|
end
|
||||||
|
@ -216,10 +216,6 @@ module Actions
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def maybe_attach_legal_doc
|
|
||||||
Actions::BaseAction.maybe_attach_legal_doc(domain, params[:legal_document])
|
|
||||||
end
|
|
||||||
|
|
||||||
def ask_registrant_verification
|
def ask_registrant_verification
|
||||||
if verify_registrant_change? && !bypass_verify &&
|
if verify_registrant_change? && !bypass_verify &&
|
||||||
Setting.request_confirmation_on_registrant_change_enabled
|
Setting.request_confirmation_on_registrant_change_enabled
|
||||||
|
@ -243,15 +239,10 @@ module Actions
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
|
|
||||||
def verify_public_key_integrity(dnssec)
|
def verify_public_key_integrity(pub)
|
||||||
return if dnssec[:public_key].blank?
|
return if Dnskey.pub_key_base64?(pub)
|
||||||
|
|
||||||
value = dnssec[:public_key]
|
domain.add_epp_error(2005, nil, nil, %i[dnskeys invalid])
|
||||||
if !value.is_a?(String) || Base64.strict_encode64(Base64.strict_decode64(value)) != value
|
|
||||||
domain.add_epp_error('2005', nil, nil, %i[dnskeys invalid])
|
|
||||||
end
|
|
||||||
rescue ArgumentError
|
|
||||||
domain.add_epp_error('2005', nil, nil, %i[dnskeys invalid])
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -128,5 +128,13 @@ class Dnskey < ApplicationRecord
|
||||||
def bin_to_hex(s)
|
def bin_to_hex(s)
|
||||||
s.each_byte.map { |b| format('%02X', b) }.join
|
s.each_byte.map { |b| format('%02X', b) }.join
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def pub_key_base64?(pub)
|
||||||
|
return unless pub&.is_a?(String)
|
||||||
|
|
||||||
|
Base64.strict_encode64(Base64.strict_decode64(pub)) == pub
|
||||||
|
rescue ArgumentError
|
||||||
|
false
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -10,13 +10,14 @@ module Deserializers
|
||||||
def initialize(frame, registrar)
|
def initialize(frame, registrar)
|
||||||
@frame = frame
|
@frame = frame
|
||||||
@registrar = registrar
|
@registrar = registrar
|
||||||
|
@legal_document ||= ::Deserializers::Xml::LegalDocument.new(frame).call
|
||||||
end
|
end
|
||||||
|
|
||||||
def call
|
def call
|
||||||
obj = { domain: frame.css('name')&.text, registrant: registrant, contacts: contacts,
|
obj = { domain: frame.css('name')&.text, registrant: registrant, contacts: contacts,
|
||||||
auth_info: if_present('authInfo > pw'), nameservers: nameservers,
|
auth_info: if_present('authInfo > pw'), nameservers: nameservers,
|
||||||
registrar_id: registrar, statuses: statuses, dns_keys: dns_keys,
|
registrar_id: registrar, statuses: statuses, dns_keys: dns_keys,
|
||||||
reserved_pw: if_present('reserved > pw'), legal_document: legal_document }
|
reserved_pw: if_present('reserved > pw'), legal_document: @legal_document }
|
||||||
|
|
||||||
obj.reject { |_key, val| val.blank? }
|
obj.reject { |_key, val| val.blank? }
|
||||||
end
|
end
|
||||||
|
@ -78,10 +79,6 @@ module Deserializers
|
||||||
s
|
s
|
||||||
end
|
end
|
||||||
|
|
||||||
def legal_document
|
|
||||||
@legal_document ||= ::Deserializers::Xml::LegalDocument.new(frame).call
|
|
||||||
end
|
|
||||||
|
|
||||||
def if_present(css_path)
|
def if_present(css_path)
|
||||||
return if frame.css(css_path).blank?
|
return if frame.css(css_path).blank?
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue