mirror of
https://github.com/internetee/registry.git
synced 2025-07-28 21:46:24 +02:00
Fixed codeclimate
This commit is contained in:
parent
637cabf95f
commit
285fa138e6
2 changed files with 11 additions and 2 deletions
|
@ -10,6 +10,7 @@ module Eeid
|
||||||
rescue_from Shunter::ThrottleError, with: :handle_throttle_error
|
rescue_from Shunter::ThrottleError, with: :handle_throttle_error
|
||||||
|
|
||||||
# POST /eeid/webhooks/identification_requests
|
# POST /eeid/webhooks/identification_requests
|
||||||
|
|
||||||
def create
|
def create
|
||||||
return render_unauthorized unless ip_whitelisted?
|
return render_unauthorized unless ip_whitelisted?
|
||||||
return render_invalid_signature unless valid_hmac_signature?(request.headers['X-HMAC-Signature'])
|
return render_invalid_signature unless valid_hmac_signature?(request.headers['X-HMAC-Signature'])
|
||||||
|
@ -17,8 +18,7 @@ module Eeid
|
||||||
verify_contact(permitted_params[:reference])
|
verify_contact(permitted_params[:reference])
|
||||||
render json: { status: 'success' }, status: :ok
|
render json: { status: 'success' }, status: :ok
|
||||||
rescue StandardError => e
|
rescue StandardError => e
|
||||||
Rails.logger.error("Error handling webhook: #{e.message}")
|
handle_error(e)
|
||||||
render json: { error: 'Internal Server Error' }, status: :internal_server_error
|
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
@ -64,6 +64,11 @@ module Eeid
|
||||||
OpenStruct.new(id: request.remote_ip, class: 'WebhookRequest')
|
OpenStruct.new(id: request.remote_ip, class: 'WebhookRequest')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def handle_error(error)
|
||||||
|
Rails.logger.error("Error handling webhook: #{error.message}")
|
||||||
|
render json: { error: 'Internal Server Error' }, status: :internal_server_error
|
||||||
|
end
|
||||||
|
|
||||||
def handle_throttle_error
|
def handle_throttle_error
|
||||||
render json: { error: Shunter.default_error_message }, status: :bad_request
|
render json: { error: Shunter.default_error_message }, status: :bad_request
|
||||||
end
|
end
|
||||||
|
|
|
@ -259,3 +259,7 @@ allow_accr_endspoints: 'true'
|
||||||
whitelist_companies:
|
whitelist_companies:
|
||||||
- '12345678'
|
- '12345678'
|
||||||
- '87654321'
|
- '87654321'
|
||||||
|
|
||||||
|
eeid_base_url: 'http://eid.test'
|
||||||
|
ident_service_client_id: 123
|
||||||
|
ident_service_client_secret: 321
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue