From 974b3e5bb216df7c5fd4984f15a8c89828ecfee8 Mon Sep 17 00:00:00 2001
From: Marvin Martinson
Date: Tue, 1 Jun 2021 19:20:39 +0000
Subject: [PATCH] Communication from CN to Mongo id
---
static/js/certidude.js | 31 +++++++++++++++++--------------
templates/views/request.html | 6 +++---
templates/views/signed.html | 14 +++++++-------
templates/views/tags.html | 2 +-
4 files changed, 28 insertions(+), 25 deletions(-)
diff --git a/static/js/certidude.js b/static/js/certidude.js
index 027e395..d61c8b0 100644
--- a/static/js/certidude.js
+++ b/static/js/certidude.js
@@ -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 }}));
}
})
diff --git a/templates/views/request.html b/templates/views/request.html
index 94f6e01..716e178 100644
--- a/templates/views/request.html
+++ b/templates/views/request.html
@@ -19,11 +19,11 @@
{% if session.tagging %}
-
+
{% include "views/tags.html" %}
{% endif %}
@@ -41,24 +41,24 @@
Revoke due to key compromise
+ 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
Revoke due to cessation of operation
+ 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
Revoke due to withdrawn privilege
+ 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