mirror of
https://github.com/internetee/registry.git
synced 2025-07-30 14:36:22 +02:00
feat: improve certificate download extensions
Update certificate download functionality to use appropriate file extensions: - Use .p12 extension for PKCS#12 files - Keep .pem extension for PEM-encoded files (CSR, CRT, private key) This change ensures that downloaded certificate files have the correct extension based on their format, making it easier for users to identify and use the files correctly.
This commit is contained in:
parent
51035d1ddf
commit
5355397025
15 changed files with 281 additions and 262 deletions
29
app/controllers/repp/v1/certificates/p12_controller.rb
Normal file
29
app/controllers/repp/v1/certificates/p12_controller.rb
Normal file
|
@ -0,0 +1,29 @@
|
|||
module Repp
|
||||
module V1
|
||||
module Certificates
|
||||
class P12Controller < BaseController
|
||||
load_and_authorize_resource param_method: :cert_params
|
||||
|
||||
THROTTLED_ACTIONS = %i[create].freeze
|
||||
include Shunter::Integration::Throttle
|
||||
|
||||
api :POST, '/repp/v1/certificates/p12'
|
||||
desc 'Generate a P12 certificate'
|
||||
def create
|
||||
api_user_id = cert_params[:api_user_id]
|
||||
render_error(I18n.t('errors.messages.not_found'), :not_found) and return if api_user_id.blank?
|
||||
|
||||
api_user = current_user.registrar.api_users.find(api_user_id)
|
||||
certificate = Certificate.generate_for_api_user(api_user: api_user)
|
||||
render_success(data: { certificate: certificate })
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def cert_params
|
||||
params.require(:certificate).permit(:api_user_id)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue