mirror of
https://github.com/internetee/registry.git
synced 2025-07-03 09:43:36 +02:00
Add whitelist to EPP
This commit is contained in:
parent
9b4e9ca12c
commit
dc1ad9e6c5
6 changed files with 28 additions and 5 deletions
|
@ -9,7 +9,7 @@ module Repp
|
||||||
|
|
||||||
before do
|
before do
|
||||||
unless Rails.env.development?
|
unless Rails.env.development?
|
||||||
error! 'IP is not whitelisted', 401 unless @current_user.registrar.repp_ip_white?(request.ip)
|
error! I18n.t('ip_is_not_whitelisted'), 401 unless @current_user.registrar.repp_ip_white?(request.ip)
|
||||||
end
|
end
|
||||||
|
|
||||||
next if Rails.env.test? || Rails.env.development?
|
next if Rails.env.test? || Rails.env.development?
|
||||||
|
|
|
@ -80,7 +80,11 @@ class EppController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
# VALIDATION
|
# VALIDATION
|
||||||
|
# rubocop: disable Metrics/PerceivedComplexity
|
||||||
|
# rubocop: disable Metrics/CyclomaticComplexity
|
||||||
def validate_request
|
def validate_request
|
||||||
|
handle_errors and return unless ip_white?
|
||||||
|
|
||||||
validation_method = "validate_#{params[:action]}"
|
validation_method = "validate_#{params[:action]}"
|
||||||
return unless respond_to?(validation_method, true)
|
return unless respond_to?(validation_method, true)
|
||||||
send(validation_method)
|
send(validation_method)
|
||||||
|
@ -93,6 +97,22 @@ class EppController < ApplicationController
|
||||||
|
|
||||||
handle_errors and return if epp_errors.any?
|
handle_errors and return if epp_errors.any?
|
||||||
end
|
end
|
||||||
|
# rubocop: enable Metrics/PerceivedComplexity
|
||||||
|
# rubocop: enable Metrics/CyclomaticComplexity
|
||||||
|
|
||||||
|
def ip_white?
|
||||||
|
if current_user
|
||||||
|
unless current_user.registrar.epp_ip_white?(request.ip)
|
||||||
|
epp_errors << {
|
||||||
|
msg: t('ip_is_not_whitelisted'),
|
||||||
|
code: '2201'
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
true
|
||||||
|
end
|
||||||
|
|
||||||
# let's follow grape's validations: https://github.com/intridea/grape/#parameter-validation-and-coercion
|
# let's follow grape's validations: https://github.com/intridea/grape/#parameter-validation-and-coercion
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ class Registrar::DomainsController < Registrar::DeppController # EPP controller
|
||||||
if response_ok?
|
if response_ok?
|
||||||
render 'info'
|
render 'info'
|
||||||
else
|
else
|
||||||
flash[:alert] = t(:domain_not_found)
|
flash[:alert] = @data.css('msg').text
|
||||||
redirect_to registrar_domains_url and return
|
redirect_to registrar_domains_url and return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -32,6 +32,8 @@ module Depp
|
||||||
|
|
||||||
def request(xml)
|
def request(xml)
|
||||||
Nokogiri::XML(server.request(xml)).remove_namespaces!
|
Nokogiri::XML(server.request(xml)).remove_namespaces!
|
||||||
|
rescue EppErrorResponse => e
|
||||||
|
Nokogiri::XML(e.response_xml.to_s).remove_namespaces!
|
||||||
end
|
end
|
||||||
|
|
||||||
def repp_request(path, params = {})
|
def repp_request(path, params = {})
|
||||||
|
|
|
@ -795,3 +795,4 @@ en:
|
||||||
domain_registrant_change_rejected_body: 'You have rejected domain owner change.'
|
domain_registrant_change_rejected_body: 'You have rejected domain owner change.'
|
||||||
registrant_domain_verification_rejected: 'Domain owner change has been rejected successfully.'
|
registrant_domain_verification_rejected: 'Domain owner change has been rejected successfully.'
|
||||||
registrant_domain_verification_rejected_failed: 'Something went wrong'
|
registrant_domain_verification_rejected_failed: 'Something went wrong'
|
||||||
|
ip_is_not_whitelisted: 'IP is not whitelisted'
|
||||||
|
|
|
@ -10,7 +10,7 @@ Fabricator(:registrar) do
|
||||||
code { sequence(:code) { |i| "REGISTRAR#{i}" } }
|
code { sequence(:code) { |i| "REGISTRAR#{i}" } }
|
||||||
reference_no { sequence(:reference_no) { |i| "RF#{i}" } }
|
reference_no { sequence(:reference_no) { |i| "RF#{i}" } }
|
||||||
accounts(count: 1)
|
accounts(count: 1)
|
||||||
white_ips { [Fabricate(:white_ip_repp, ipv4: '127.0.0.1')] }
|
white_ips { [Fabricate(:white_ip_repp, ipv4: '127.0.0.1'), Fabricate(:white_ip, ipv4: '127.0.0.1')] }
|
||||||
end
|
end
|
||||||
|
|
||||||
Fabricator(:registrar_with_no_account_activities, from: :registrar) do
|
Fabricator(:registrar_with_no_account_activities, from: :registrar) do
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue