mirror of
https://github.com/internetee/registry.git
synced 2025-05-30 17:33:57 +02:00
Merge branch 'master' of github.com:domify/registry
This commit is contained in:
commit
5f32c1cfd4
11 changed files with 1231 additions and 882 deletions
|
@ -1,3 +1,6 @@
|
||||||
|
20.07.2015
|
||||||
|
* New syntax for setting webclient IP-s (see config/application-example.yml)
|
||||||
|
|
||||||
14.07.2015
|
14.07.2015
|
||||||
|
|
||||||
* Updated que init script doc example, now status and stop works faster
|
* Updated que init script doc example, now status and stop works faster
|
||||||
|
|
|
@ -8,7 +8,8 @@ module Repp
|
||||||
end
|
end
|
||||||
|
|
||||||
before do
|
before do
|
||||||
if request.ip != ENV['webclient_ip']
|
webclient_request = ENV['webclient_ips'].split(',').map(&:strip).include?(request.ip)
|
||||||
|
unless webclient_request
|
||||||
error! I18n.t('ip_is_not_whitelisted'), 401 unless @current_user.registrar.api_ip_white?(request.ip)
|
error! I18n.t('ip_is_not_whitelisted'), 401 unless @current_user.registrar.api_ip_white?(request.ip)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -20,7 +21,7 @@ module Repp
|
||||||
message = 'Certificate mismatch! Cert common name should be:'
|
message = 'Certificate mismatch! Cert common name should be:'
|
||||||
request_name = env['HTTP_SSL_CLIENT_S_DN_CN']
|
request_name = env['HTTP_SSL_CLIENT_S_DN_CN']
|
||||||
|
|
||||||
if request.ip == ENV['webclient_ip']
|
if webclient_request
|
||||||
webclient_cert_name = ENV['webclient_cert_common_name'] || 'webclient'
|
webclient_cert_name = ENV['webclient_cert_common_name'] || 'webclient'
|
||||||
error! "Webclient #{message} #{webclient_cert_name}", 401 if webclient_cert_name != request_name
|
error! "Webclient #{message} #{webclient_cert_name}", 401 if webclient_cert_name != request_name
|
||||||
else
|
else
|
||||||
|
|
|
@ -91,17 +91,12 @@ class Epp::DomainsController < EppController
|
||||||
render_epp_response '/epp/domains/check'
|
render_epp_response '/epp/domains/check'
|
||||||
end
|
end
|
||||||
|
|
||||||
# rubocop: disable Metrics/MethodLength
|
|
||||||
def renew
|
def renew
|
||||||
authorize! :renew, @domain
|
authorize! :renew, @domain
|
||||||
|
|
||||||
period = params[:parsed_frame].css('period').text.presence || 1
|
period_element = params[:parsed_frame].css('period').text
|
||||||
period_unit = 'y'
|
period = (period_element.to_i == 0) ? 1 : period_element.to_i
|
||||||
period_element = params[:parsed_frame].css('period').first
|
period_unit = Epp::Domain.parse_period_unit_from_frame(params[:parsed_frame]) || 'y'
|
||||||
|
|
||||||
if period_element.present? && period_element['unit'].present?
|
|
||||||
period_unit = period_element['unit']
|
|
||||||
end
|
|
||||||
|
|
||||||
ActiveRecord::Base.transaction do
|
ActiveRecord::Base.transaction do
|
||||||
success = @domain.renew(
|
success = @domain.renew(
|
||||||
|
@ -128,7 +123,6 @@ class Epp::DomainsController < EppController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
# rubocop: enable Metrics/MethodLength
|
|
||||||
|
|
||||||
def transfer
|
def transfer
|
||||||
authorize! :transfer, @domain, @password
|
authorize! :transfer, @domain, @password
|
||||||
|
@ -161,6 +155,8 @@ class Epp::DomainsController < EppController
|
||||||
@prefix = nil
|
@prefix = nil
|
||||||
requires 'extension > extdata > legalDocument'
|
requires 'extension > extdata > legalDocument'
|
||||||
|
|
||||||
|
optional_attribute 'period', 'unit', values: %w(d m y)
|
||||||
|
|
||||||
status_editing_disabled
|
status_editing_disabled
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,8 @@ class Epp::SessionsController < EppController
|
||||||
success = true
|
success = true
|
||||||
@api_user = ApiUser.find_by(login_params)
|
@api_user = ApiUser.find_by(login_params)
|
||||||
|
|
||||||
if request.ip == ENV['webclient_ip'] && !Rails.env.test? && !Rails.env.development?
|
webclient_request = ENV['webclient_ips'].split(',').map(&:strip).include?(request.ip)
|
||||||
|
if webclient_request && !Rails.env.test? && !Rails.env.development?
|
||||||
client_md5 = Certificate.parse_md_from_string(request.env['HTTP_SSL_CLIENT_CERT'])
|
client_md5 = Certificate.parse_md_from_string(request.env['HTTP_SSL_CLIENT_CERT'])
|
||||||
server_md5 = Certificate.parse_md_from_string(File.read(ENV['cert_path']))
|
server_md5 = Certificate.parse_md_from_string(File.read(ENV['cert_path']))
|
||||||
if client_md5 != server_md5
|
if client_md5 != server_md5
|
||||||
|
@ -26,7 +27,7 @@ class Epp::SessionsController < EppController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if request.ip != ENV['webclient_ip'] && @api_user
|
if !webclient_request && @api_user
|
||||||
unless @api_user.api_pki_ok?(request.env['HTTP_SSL_CLIENT_CERT'], request.env['HTTP_SSL_CLIENT_S_DN_CN'])
|
unless @api_user.api_pki_ok?(request.env['HTTP_SSL_CLIENT_CERT'], request.env['HTTP_SSL_CLIENT_S_DN_CN'])
|
||||||
epp_errors << {
|
epp_errors << {
|
||||||
msg: 'Authentication error; server closing connection (certificate is not valid)',
|
msg: 'Authentication error; server closing connection (certificate is not valid)',
|
||||||
|
@ -76,7 +77,7 @@ class Epp::SessionsController < EppController
|
||||||
if success
|
if success
|
||||||
if parsed_frame.css('newPW').first
|
if parsed_frame.css('newPW').first
|
||||||
unless @api_user.update(password: parsed_frame.css('newPW').first.text)
|
unless @api_user.update(password: parsed_frame.css('newPW').first.text)
|
||||||
response.headers['X-EPP-Returncode'] = '2200'
|
response.headers['X-EPP-Returncode'] = '2500'
|
||||||
handle_errors(@api_user) and return
|
handle_errors(@api_user) and return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -85,7 +86,7 @@ class Epp::SessionsController < EppController
|
||||||
epp_session.update_column(:registrar_id, @api_user.registrar_id)
|
epp_session.update_column(:registrar_id, @api_user.registrar_id)
|
||||||
render_epp_response('login_success')
|
render_epp_response('login_success')
|
||||||
else
|
else
|
||||||
response.headers['X-EPP-Returncode'] = '2200'
|
response.headers['X-EPP-Returncode'] = '2500'
|
||||||
handle_errors
|
handle_errors
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -95,7 +96,8 @@ class Epp::SessionsController < EppController
|
||||||
# rubocop: enable Metrics/CyclomaticComplexity
|
# rubocop: enable Metrics/CyclomaticComplexity
|
||||||
|
|
||||||
def ip_white?
|
def ip_white?
|
||||||
return true if request.ip == ENV['webclient_ip']
|
webclient_request = ENV['webclient_ips'].split(',').map(&:strip).include?(request.ip)
|
||||||
|
return true if webclient_request
|
||||||
if @api_user
|
if @api_user
|
||||||
return false unless @api_user.registrar.api_ip_white?(request.ip)
|
return false unless @api_user.registrar.api_ip_white?(request.ip)
|
||||||
end
|
end
|
||||||
|
|
|
@ -25,7 +25,7 @@ ca_key_path: '/home/registry/registry/shared/ca/private/ca.key.pem'
|
||||||
ca_key_password: 'your-root-key-password'
|
ca_key_password: 'your-root-key-password'
|
||||||
|
|
||||||
# EPP server configuration
|
# EPP server configuration
|
||||||
webclient_ip: '127.0.0.1'
|
webclient_ips: '127.0.0.1,0.0.0.0' #ips, separated with commas
|
||||||
webclient_cert_common_name: 'webclient'
|
webclient_cert_common_name: 'webclient'
|
||||||
# Contact epp will not accept org value by default
|
# Contact epp will not accept org value by default
|
||||||
# and returns 2306 "Parameter value policy error"
|
# and returns 2306 "Parameter value policy error"
|
||||||
|
@ -72,7 +72,7 @@ sk_digi_doc_service_name: 'EIS test'
|
||||||
|
|
||||||
# Autotest config overwrites
|
# Autotest config overwrites
|
||||||
test:
|
test:
|
||||||
webclient_ip: '127.0.0.1' # it should match to localhost ip address
|
webclient_ips: '127.0.0.1' # it should match to localhost ip address
|
||||||
crl_dir: '/var/lib/jenkins/workspace/registry/ca/crl'
|
crl_dir: '/var/lib/jenkins/workspace/registry/ca/crl'
|
||||||
crl_path: '/var/lib/jenkins/workspace/registry/ca/crl/crl.pem'
|
crl_path: '/var/lib/jenkins/workspace/registry/ca/crl/crl.pem'
|
||||||
ca_cert_path: '/var/lib/jenkins/workspace/registry/ca/certs/ca.crt.pem'
|
ca_cert_path: '/var/lib/jenkins/workspace/registry/ca/certs/ca.crt.pem'
|
||||||
|
|
|
@ -7,7 +7,7 @@ required = %w(
|
||||||
ca_cert_path
|
ca_cert_path
|
||||||
ca_key_path
|
ca_key_path
|
||||||
ca_key_password
|
ca_key_password
|
||||||
webclient_ip
|
webclient_ips
|
||||||
legal_documents_dir
|
legal_documents_dir
|
||||||
bank_statement_import_dir
|
bank_statement_import_dir
|
||||||
time_zone
|
time_zone
|
||||||
|
|
|
@ -100,7 +100,7 @@ Configure registry registry/shared/config/application.yml to match the CA settin
|
||||||
|
|
||||||
Configure registry epp registry-epp/shared/config/application.yml:
|
Configure registry epp registry-epp/shared/config/application.yml:
|
||||||
|
|
||||||
webclient_ip: '54.154.91.240'
|
webclient_ips: '54.154.91.240'
|
||||||
|
|
||||||
Configure EPP port 700 virtual host:
|
Configure EPP port 700 virtual host:
|
||||||
|
|
||||||
|
|
2028
doc/epp-examples.md
2028
doc/epp-examples.md
File diff suppressed because it is too large
Load diff
|
@ -18,6 +18,7 @@ Domain name mapping protocol short version:
|
||||||
<domain:period> 0-1 Registration period for domain.
|
<domain:period> 0-1 Registration period for domain.
|
||||||
Must add up to 1 / 2 / 3 years.
|
Must add up to 1 / 2 / 3 years.
|
||||||
Attribute: unit="y/m/d"
|
Attribute: unit="y/m/d"
|
||||||
|
Default is 1 year.
|
||||||
<domain:registrant> 1 Contact reference to the registrant
|
<domain:registrant> 1 Contact reference to the registrant
|
||||||
Attribute:
|
Attribute:
|
||||||
"verified" # optional, allowed values 'yes', 'no'
|
"verified" # optional, allowed values 'yes', 'no'
|
||||||
|
|
|
@ -435,6 +435,24 @@ describe 'EPP Domain', epp: true do
|
||||||
a.activity_type = AccountActivity::CREATE
|
a.activity_type = AccountActivity::CREATE
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'creates a domain without period' do
|
||||||
|
old_balance = @registrar1.balance
|
||||||
|
old_activities = @registrar1.cash_account.account_activities.count
|
||||||
|
xml = domain_create_xml(period: nil)
|
||||||
|
|
||||||
|
response = epp_plain_request(xml)
|
||||||
|
response[:msg].should == 'Command completed successfully'
|
||||||
|
response[:result_code].should == '1000'
|
||||||
|
Domain.last.valid_to.should be_within(60).of(1.years.since)
|
||||||
|
@registrar1.balance.should be < old_balance
|
||||||
|
@registrar1.cash_account.account_activities.count.should == old_activities + 1
|
||||||
|
a = @registrar1.cash_account.account_activities.last
|
||||||
|
a.description.should == "Create #{Domain.last.name}"
|
||||||
|
a.sum.should == -BigDecimal.new('10.0')
|
||||||
|
a.activity_type = AccountActivity::CREATE
|
||||||
|
a.log_pricelist_id.should == @pricelist_reg_1_year.id
|
||||||
|
end
|
||||||
|
|
||||||
it 'does not create a domain with invalid period' do
|
it 'does not create a domain with invalid period' do
|
||||||
old_balance = @registrar1.balance
|
old_balance = @registrar1.balance
|
||||||
old_activities = @registrar1.cash_account.account_activities.count
|
old_activities = @registrar1.cash_account.account_activities.count
|
||||||
|
@ -450,6 +468,24 @@ describe 'EPP Domain', epp: true do
|
||||||
@registrar1.cash_account.account_activities.count.should == old_activities
|
@registrar1.cash_account.account_activities.count.should == old_activities
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'does not create a domain with invalid period unit' do
|
||||||
|
xml = domain_create_xml({
|
||||||
|
period: { value: '1', attrs: { unit: '' } }
|
||||||
|
})
|
||||||
|
|
||||||
|
response = epp_plain_request(xml, validate_input: false)
|
||||||
|
response[:results][0][:msg].should == 'Attribute is invalid: unit'
|
||||||
|
response[:results][0][:result_code].should == '2306'
|
||||||
|
|
||||||
|
xml = domain_create_xml({
|
||||||
|
period: { value: '1', attrs: { unit: 'bla' } }
|
||||||
|
})
|
||||||
|
|
||||||
|
response = epp_plain_request(xml, validate_input: false)
|
||||||
|
response[:results][0][:msg].should == 'Attribute is invalid: unit'
|
||||||
|
response[:results][0][:result_code].should == '2306'
|
||||||
|
end
|
||||||
|
|
||||||
it 'creates a domain with multiple dnskeys' do
|
it 'creates a domain with multiple dnskeys' do
|
||||||
xml = domain_create_xml({}, {
|
xml = domain_create_xml({}, {
|
||||||
_anonymus: [
|
_anonymus: [
|
||||||
|
|
|
@ -2,7 +2,7 @@ require 'rails_helper'
|
||||||
|
|
||||||
describe Repp::AccountV1 do
|
describe Repp::AccountV1 do
|
||||||
it 'should fail without whitelisted IP' do
|
it 'should fail without whitelisted IP' do
|
||||||
ENV['webclient_ip'] = '192.188.1.1'
|
ENV['webclient_ips'] = '192.188.1.1'
|
||||||
@registrar1 = Fabricate(:registrar, white_ips: [Fabricate(:white_ip_registrar)])
|
@registrar1 = Fabricate(:registrar, white_ips: [Fabricate(:white_ip_registrar)])
|
||||||
@api_user = Fabricate(:api_user, registrar: @registrar1)
|
@api_user = Fabricate(:api_user, registrar: @registrar1)
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ describe Repp::AccountV1 do
|
||||||
body = JSON.parse(response.body)
|
body = JSON.parse(response.body)
|
||||||
|
|
||||||
body['error'].should == 'IP is not whitelisted'
|
body['error'].should == 'IP is not whitelisted'
|
||||||
ENV['webclient_ip'] = '127.0.0.1'
|
ENV['webclient_ips'] = '127.0.0.1'
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with valid registrar' do
|
context 'with valid registrar' do
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue