1
0
Fork 0
This repository has been archived on 2023-03-27. You can view files and clone it, but cannot push or open issues or pull requests.
lpr-partynest/app/controllers/private_keys_controller.rb

30 lines
652 B
Ruby

# frozen_string_literal: true
class PrivateKeysController < ApplicationController
before_action :set_asymmetric_key
before_action :set_secret
# GET /private_keys/:id
def show
authorize PrivateKey.new(@asymmetric_key)
@asymmetric_key.decrypt_private_key_pem
respond_to do |format|
format.key do
send_data @asymmetric_key.private_key_pem, filename: 'private.key'
end
end
end
private
def set_asymmetric_key
@asymmetric_key = AsymmetricKey.find params[:id]
end
def set_secret
@asymmetric_key.private_key_pem_secret =
Base64.urlsafe_decode64 params[:private_key_pem_secret]
end
end