mirror of
https://github.com/internetee/registry.git
synced 2025-07-29 22:16:19 +02:00
Added client cert control to every REPP APi request
This commit is contained in:
parent
7ec5c914bc
commit
9f6c628453
2 changed files with 11 additions and 10 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue