Added client cert control to every REPP APi request

This commit is contained in:
Sergei Tsõganov 2022-06-13 16:26:42 +03:00
parent 7ec5c914bc
commit 9f6c628453
2 changed files with 11 additions and 10 deletions

View file

@ -7,6 +7,7 @@ module Repp
before_action :authenticate_user
before_action :validate_webclient_ca
before_action :check_ip_restriction
before_action :validate_client_certs
before_action :set_paper_trail_whodunnit
private
@ -144,6 +145,15 @@ module Repp
render(json: @response, status: :unauthorized)
end
def validate_client_certs
return if Rails.env.development? || Rails.env.test?
return if @current_user.pki_ok?(request.env['HTTP_SSL_CLIENT_CERT'],
request.env['HTTP_SSL_CLIENT_S_DN_CN'], api: false)
@response = { code: 2202, message: 'Invalid certificate' }
render(json: @response, status: :unauthorized)
end
def logger
Rails.logger
end