mirror of
https://github.com/laurivosandi/certidude
synced 2025-10-30 17:09:19 +00:00
api: Preliminary API call for listing client leases
This commit is contained in:
@@ -21,9 +21,9 @@
|
||||
|
||||
<h1>Signed certificates</h1>
|
||||
|
||||
<ul>
|
||||
<ul id="signed_certificates">
|
||||
{% for j in authority.signed | sort | reverse %}
|
||||
<li id="certificate_{{ j.sha256sum }}">
|
||||
<li id="certificate_{{ j.sha256sum }}" data-dn="{{ j.subject }}">
|
||||
<a class="button" href="/api/{{authority.slug}}/signed/{{j.subject}}/">Fetch</a>
|
||||
<button onClick="javascript:$.ajax({url:'/api/{{authority.slug}}/signed/{{j.subject.CN}}/',type:'delete'});">Revoke</button>
|
||||
|
||||
@@ -51,6 +51,9 @@
|
||||
</div>
|
||||
|
||||
|
||||
<div class="status">
|
||||
{% include 'status.html' %}
|
||||
</div>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
||||
@@ -49,6 +49,29 @@ $(document).ready(function() {
|
||||
});
|
||||
|
||||
$("#container").html(nunjucks.render('authority.html', { authority: authority, session: session }));
|
||||
|
||||
$.ajax({
|
||||
method: "GET",
|
||||
url: "/api/ca/" + authority.slug + "/lease/",
|
||||
dataType: "json",
|
||||
success: function(leases, status, xhr) {
|
||||
console.info("Got leases:", leases);
|
||||
for (var j = 0; j < leases.length; j++) {
|
||||
var $status = $("#signed_certificates [data-dn='" + leases[j].dn + "'] .status");
|
||||
if (!$status.length) {
|
||||
console.info("Detected rogue client:", leases[j]);
|
||||
continue;
|
||||
}
|
||||
$status.html(nunjucks.render('status.html', {
|
||||
lease: {
|
||||
address: leases[j].address,
|
||||
dn: leases[j].dn,
|
||||
acquired: new Date(leases[j].acquired).toLocaleString(),
|
||||
released: leases[j].released ? new Date(leases[j].released).toLocaleString() : null
|
||||
}}));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
16
certidude/static/status.html
Normal file
16
certidude/static/status.html
Normal file
@@ -0,0 +1,16 @@
|
||||
<svg height="32" width="32">
|
||||
<circle cx="16" cy="16" r="13" stroke="black" stroke-width="3" fill="{% if lease %}{% if lease.released %}green{%else %}red{% endif %}{% else %}yellow{% endif %}" />
|
||||
</svg>
|
||||
|
||||
<span>
|
||||
|
||||
{% if lease %}
|
||||
{% if lease.released %}
|
||||
Last seen {{ lease.released }} at {{ lease.address }}
|
||||
{% else %}
|
||||
Online since {{ lease.acquired }} at {{ lease.address }}
|
||||
{% endif %}
|
||||
{% else %}
|
||||
Not seen
|
||||
{% endif %}
|
||||
</span>
|
||||
|
After Width: | Height: | Size: 428 B |
Reference in New Issue
Block a user