mirror of
https://github.com/internetee/registry.git
synced 2025-05-17 17:59:47 +02:00
Refactor epp session errors #2716
This commit is contained in:
parent
9f2304a865
commit
630865a8b7
1 changed files with 31 additions and 7 deletions
|
@ -17,35 +17,59 @@ class Epp::SessionsController < EppController
|
||||||
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
|
||||||
@msg = 'Authentication error; server closing connection (certificate is not valid)'
|
epp_errors << {
|
||||||
|
msg: 'Authentication error; server closing connection (certificate is not valid)',
|
||||||
|
code: '2501'
|
||||||
|
}
|
||||||
|
|
||||||
success = false
|
success = false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if request.ip != ENV['webclient_ip'] && @api_user
|
if request.ip != ENV['webclient_ip'] && @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'])
|
||||||
@msg = 'Authentication error; server closing connection (certificate is not valid)'
|
epp_errors << {
|
||||||
|
msg: 'Authentication error; server closing connection (certificate is not valid)',
|
||||||
|
code: '2501'
|
||||||
|
}
|
||||||
|
|
||||||
success = false
|
success = false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if success && !@api_user
|
if success && !@api_user
|
||||||
@msg = 'Authentication error; server closing connection (API user not found)'
|
epp_errors << {
|
||||||
|
msg: 'Authentication error; server closing connection (API user not found)',
|
||||||
|
code: '2501'
|
||||||
|
}
|
||||||
|
|
||||||
success = false
|
success = false
|
||||||
end
|
end
|
||||||
|
|
||||||
if success && !@api_user.try(:active)
|
if success && !@api_user.try(:active)
|
||||||
@msg = 'Authentication error; server closing connection (API user is not active)'
|
epp_errors << {
|
||||||
|
msg: 'Authentication error; server closing connection (API user is not active)',
|
||||||
|
code: '2501'
|
||||||
|
}
|
||||||
|
|
||||||
success = false
|
success = false
|
||||||
end
|
end
|
||||||
|
|
||||||
if success && !ip_white?
|
if success && !ip_white?
|
||||||
@msg = 'Authentication error; server closing connection (IP is not whitelisted)'
|
epp_errors << {
|
||||||
|
msg: 'Authentication error; server closing connection (IP is not whitelisted)',
|
||||||
|
code: '2501'
|
||||||
|
}
|
||||||
|
|
||||||
success = false
|
success = false
|
||||||
end
|
end
|
||||||
|
|
||||||
if success && !connection_limit_ok?
|
if success && !connection_limit_ok?
|
||||||
@msg = 'Authentication error; server closing connection (connection limit reached)'
|
epp_errors << {
|
||||||
|
msg: 'Authentication error; server closing connection (connection limit reached)',
|
||||||
|
code: '2501'
|
||||||
|
}
|
||||||
|
|
||||||
success = false
|
success = false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -62,7 +86,7 @@ class Epp::SessionsController < EppController
|
||||||
render_epp_response('login_success')
|
render_epp_response('login_success')
|
||||||
else
|
else
|
||||||
response.headers['X-EPP-Returncode'] = '2200'
|
response.headers['X-EPP-Returncode'] = '2200'
|
||||||
render_epp_response('login_fail')
|
handle_errors
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
# rubocop: enable Metrics/MethodLength
|
# rubocop: enable Metrics/MethodLength
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue