-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add P12 certificate generation and display
- Add P12 certificate generation button to API user certificates view - Create new partials for displaying private key and P12 certificate details - Add expires_at field to P12 certificate display - Add new routes for P12 certificate generation - Add translations for new certificate features in English and Estonian
- Loading branch information
1 parent
e1413b6
commit c628ee8
Showing
9 changed files
with
126 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
module Certificates | ||
class P12Controller < BaseController | ||
def create | ||
conn = ApiConnector::Certificates::P12::Creator.new(**auth_info) | ||
result = conn.call_action(payload: p12_payload) | ||
handle_response(result); return if performed? | ||
|
||
flash.notice = @message | ||
redirect_to api_user_path(params[:api_user_id]) | ||
end | ||
|
||
private | ||
|
||
def p12_payload | ||
{ | ||
api_user_id: params[:api_user_id] | ||
} | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
class ApiConnector | ||
module Certificates | ||
module P12 | ||
class Creator < ApiConnector | ||
ACTION = 'create_p12' | ||
ENDPOINT = { | ||
method: 'post', | ||
endpoint: '/certificates/p12', | ||
}.freeze | ||
|
||
def create_p12(payload: nil) | ||
request(url: endpoint_url, method: method, params: p12_params(payload)) | ||
end | ||
|
||
private | ||
|
||
def p12_params(payload) | ||
{ | ||
api_user_id: payload[:api_user_id] | ||
} | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<div class="page--block--header"> | ||
<div class="row between-xs"> | ||
<div class="col-xs-auto"> | ||
<h2><%= t('certificates.show.p12') %></h2> | ||
</div> | ||
<div class="col-xs-auto"> | ||
<%= | ||
link_to "#{t(:download)} <i class='fas fa-download'></i>".html_safe, | ||
download_api_user_certificate_path(@certificate[:api_user_id], @certificate[:id], 'p12'), | ||
data: { turbo: false } | ||
%> | ||
</div> | ||
</div> | ||
</div> | ||
<table class="table table__basic"> | ||
<tbody> | ||
<tr> | ||
<th><%= t('certificates.show.expires_at') %></th> | ||
<td><%= l @certificate[:expires_at].to_datetime if @certificate[:expires_at].present? %></td> | ||
</tr> | ||
</tbody> | ||
</table> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<div class="page--block--header"> | ||
<div class="row between-xs"> | ||
<div class="col-xs-auto"> | ||
<h2><%= t('certificates.show.private_key') %></h2> | ||
</div> | ||
<div class="col-xs-auto"> | ||
<%= | ||
link_to "#{t(:download)} <i class='fas fa-download'></i>".html_safe, | ||
download_api_user_certificate_path(@certificate[:api_user_id], @certificate[:id], 'private_key'), | ||
data: { turbo: false } | ||
%> | ||
</div> | ||
</div> | ||
</div> | ||
<table class="table table__basic"> | ||
<tbody> | ||
<tr> | ||
<th><%= t('certificates.show.type') %></th> | ||
<td><%= @certificate[:private_key].dig('type') %></td> | ||
</tr> | ||
</tbody> | ||
</table> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters