Communication from CN to Mongo id

This commit is contained in:
Marvin Martinson 2021-06-01 19:20:39 +00:00
parent 4254a9c567
commit 974b3e5bb2
4 changed files with 28 additions and 25 deletions

View File

@ -30,19 +30,19 @@ function onLaunchShell(common_name) {
return false;
}
function onRejectRequest(e, common_name, sha256sum) {
function onRejectRequest(e, id, sha256sum) {
$(this).button('loading');
$.ajax({
url: "/api/request/" + common_name + "/?sha256sum=" + sha256sum,
url: "/api/request/id/" + id + "/?sha256sum=" + sha256sum,
type: "delete"
});
}
function onSignRequest(e, common_name, sha256sum) {
function onSignRequest(e, id, sha256sum) {
e.preventDefault();
$(e.target).button('loading');
$.ajax({
url: "/api/request/" + common_name + "/?sha256sum=" + sha256sum,
url: "/api/request/id/" + id + "/?sha256sum=" + sha256sum,
type: "post"
});
return false;
@ -284,6 +284,7 @@ function onHashChanged() {
function onTagClicked(e) {
e.preventDefault();
var cn = $(e.target).attr("data-cn");
var cert_id = $(e.target).attr("data-id");
var id = $(e.target).attr("title");
var value = $(e.target).html();
var updated = prompt("Enter new tag or clear to remove the tag", value);
@ -291,13 +292,13 @@ function onTagClicked(e) {
$(event.target).addClass("disabled");
$.ajax({
method: "DELETE",
url: "/api/signed/" + cn + "/tag/" + id + "/"
url: "/api/signed/id/" + cert_id + "/tag/" + id + "/"
});
} else if (updated && updated != value) {
$(e.target).addClass("disabled");
$.ajax({
method: "PUT",
url: "/api/signed/" + cn + "/tag/" + id + "/",
url: "/api/signed/id/" + cert_id + "/tag/" + id + "/",
data: { value: updated },
dataType: "text",
complete: function(xhr, status) {
@ -319,13 +320,14 @@ function onNewTagClicked(e) {
var cn = $(e.target).attr("data-cn");
var key = $(e.target).attr("data-key");
var value = prompt("Enter new " + key + " tag for " + cn);
var id = $(e.target).attr("data-id");
if (!value) return;
if (value.length == 0) return;
var $container = $(".tags[data-cn='" + cn + "']");
var $container = $(".tags[data-id='" + id + "']");
$container.addClass("disabled");
$.ajax({
method: "POST",
url: "/api/signed/" + cn + "/tag/",
url: "/api/signed/id/" + id + "/tag/",
data: { value: value, key: key },
dataType: "text",
complete: function(xhr, status) {
@ -446,18 +448,19 @@ function onCertificateRevoked(e) {
}
function onTagUpdated(e) {
var cn = e.data;
console.log("Tag updated event recevied", cn);
var id = e.data;
console.log("Tag updated event recevied", id);
$.ajax({
method: "GET",
url: "/api/signed/" + cn + "/tag/",
url: "/api/signed/id/" + id + "/tag/",
dataType: "json",
success:function(tags, status, xhr) {
console.info("Updated", cn, "tags", tags);
$(".tags[data-cn='" + cn+"']").html(
console.info("Updated", id, "tags", tags);
$(".tags[data-id='" + id+"']").html(
env.render('views/tags.html', {
certificate: {
common_name: cn,
id:id,
tags:tags }}));
}
})

View File

@ -19,11 +19,11 @@
<button type="button" class="btn btn-secondary" data-toggle="collapse" data-target="#details-{{ request.sha256sum }}"><i class="fa fa-list"></i> Details</button>
<button type="button" class="btn btn-danger"
data-loading-text="<i class='fa fa-circle-o-notch fa-spin'></i> Rejecting..."
onclick="onRejectRequest(event, '{{ request.common_name }}', '{{ request.sha256sum }}');">
onclick="onRejectRequest(event, '{{ request.id }}', '{{ request.sha256sum }}');">
<i class="fa fa-trash"></i> Reject</button>
<button type="button" class="btn btn-success"
data-loading-text="<i class='fa fa-circle-o-notch fa-spin'></i> Processing Order"
onclick="onSignRequest(event, '{{ request.common_name }}', '{{ request.sha256sum }}');">
onclick="onSignRequest(event, '{{ request.id }}', '{{ request.sha256sum }}');">
<i class="fa fa-thumbs-up"></i> Approve</button>
<button type="button" class="btn btn-success dropdown-toggle dropdown-toggle-split" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span class="sr-only">Toggle Dropdown</span>
@ -32,7 +32,7 @@
{% for p in authority.signature.profiles %}
<a class="dropdown-item{% if not request.common_name.match(p.common_name) %} disabled{% endif %}"
{% if not request.common_name.match(p.common_name) %} title="Common name doesn't match expression {{ p.common_name }}"{% endif %}
href="#" onclick="javascript:$.ajax({url:'/api/request/{{request.common_name}}/?sha256sum={{ request.sha256sum }}&profile={{ p.key }}',type:'post'});">
href="#" onclick="javascript:$.ajax({url:'/api/request/id/{{request.id}}/?sha256sum={{ request.sha256sum }}&profile={{ p.key }}',type:'post'});">
{{ p.key }}, expires in {{ p.lifetime }} days</a>
{% endfor %}
</div>

View File

@ -29,7 +29,7 @@
</p>
<p>
{% if session.tagging %}
<span class="tags" data-cn="{{ certificate.common_name }}">
<span class="tags" data-cn="{{ certificate.common_name }}" data-id="{{ certificate.id }}">
{% include "views/tags.html" %}
</span>
{% endif %}
@ -41,24 +41,24 @@
<div class="btn-group">
<button type="button" class="btn btn-secondary" data-toggle="collapse" data-target="#details-{{ certificate.sha256sum }}"><i class="fa fa-list"></i> Details</button>
<button type="button" class="btn btn-danger"
onclick="javascript:$(this).button('loading');$.ajax({url:'/api/signed/{{certificate.common_name}}/?sha256sum={{ certificate.sha256sum }}',type:'delete'});">
onclick="javascript:$(this).button('loading');$.ajax({url:'/api/signed/id/{{certificate.id}}/?sha256sum={{ certificate.sha256sum }}',type:'delete'});">
<i class="fa fa-ban"></i> Revoke</button>
<button type="button" class="btn btn-danger dropdown-toggle dropdown-toggle-split" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span class="sr-only">Toggle Dropdown</span>
</button>
<div class="dropdown-menu">
<a class="dropdown-item" href="#"
onclick="javascript:$(this).button('loading');$.ajax({url:'/api/signed/{{certificate.common_name}}/?sha256sum={{ certificate.sha256sum }}&reason=key_compromise',type:'delete'});">Revoke due to key compromise</a>
onclick="javascript:$(this).button('loading');$.ajax({url:'/api/signed/id/{{certificate.id}}/?sha256sum={{ certificate.sha256sum }}&reason=key_compromise',type:'delete'});">Revoke due to key compromise</a>
<a class="dropdown-item" href="#"
onclick="javascript:$(this).button('loading');$.ajax({url:'/api/signed/{{certificate.common_name}}/?sha256sum={{ certificate.sha256sum }}&reason=cessation_of_operation',type:'delete'});">Revoke due to cessation of operation</a>
onclick="javascript:$(this).button('loading');$.ajax({url:'/api/signed/id/{{certificate.id}}/?sha256sum={{ certificate.sha256sum }}&reason=cessation_of_operation',type:'delete'});">Revoke due to cessation of operation</a>
<a class="dropdown-item" href="#"
onclick="javascript:$(this).button('loading');$.ajax({url:'/api/signed/{{certificate.common_name}}/?sha256sum={{ certificate.sha256sum }}&reason=privilege_withdrawn',type:'delete'});">Revoke due to withdrawn privilege</a>
onclick="javascript:$(this).button('loading');$.ajax({url:'/api/signed/id/{{certificate.id}}/?sha256sum={{ certificate.sha256sum }}&reason=privilege_withdrawn',type:'delete'});">Revoke due to withdrawn privilege</a>
</div>
</div>
<div class="btn-group">
{% if session.tagging %}
<button type="button" class="btn btn-default" onclick="onNewTagClicked(event);" data-key="other" data-cn="{{ certificate.common_name }}">
<button type="button" class="btn btn-default" onclick="onNewTagClicked(event);" data-key="other" data-cn="{{ certificate.common_name }}" data-id="{{ certificate.id }}">
<i class="fa fa-tag"></i> Tag</button>
<button type="button" class="btn btn-default dropdown-toggle dropdown-toggle-split" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span class="sr-only">Toggle Dropdown</span>
@ -66,7 +66,7 @@
<div class="dropdown-menu">
{% for tag_category in session.tagging %}
<a class="dropdown-item" href="#" data-key="{{ tag_category.name }}" data-cn="{{ certificate.common_name }}"
onclick="onNewTagClicked(event);">{{ tag_category.title }}</a>
onclick="onNewTagClicked(event);" data-id="{{ certificate.id }}">{{ tag_category.title }}</a>
{% endfor %}
</div>
{% endif %}

View File

@ -1,5 +1,5 @@
{% for tag in certificate.tags %}
<span data-cn="{{ certificate.common_name }}"
<span data-id="{{ certificate.id }}"
title="{{ tag }}"
class="badge badge-default"
onClick="onTagClicked(event);">{{ tag }}</span>