Certificate generation and sync, implemented proper grant and revocation flows. Pubkey uploading. Added openssh-client to Dockerfile
This commit is contained in:
@@ -46,6 +46,152 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mt-6 rounded-xl border border-gray-200 bg-white p-6 shadow-sm sm:p-8">
|
||||
<h2 class="text-base font-semibold tracking-tight text-gray-900">SSH certificates</h2>
|
||||
<p class="mt-2 text-sm text-gray-600">
|
||||
Upload your SSH public key to receive a signed certificate for server access.
|
||||
</p>
|
||||
|
||||
{% if can_add_key %}
|
||||
<form method="post" class="mt-4 space-y-3">
|
||||
{% csrf_token %}
|
||||
<input type="hidden" name="form_type" value="ssh_key">
|
||||
<div>
|
||||
<label for="{{ key_form.name.id_for_label }}" class="block text-sm font-medium text-gray-700">
|
||||
Key name
|
||||
</label>
|
||||
<div class="mt-1">
|
||||
{{ key_form.name }}
|
||||
</div>
|
||||
{% if key_form.name.errors %}
|
||||
<p class="mt-1 text-sm text-red-600">{{ key_form.name.errors|striptags }}</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div>
|
||||
<label for="{{ key_form.public_key.id_for_label }}" class="block text-sm font-medium text-gray-700">
|
||||
SSH public key
|
||||
</label>
|
||||
<div class="mt-1">
|
||||
{{ key_form.public_key }}
|
||||
</div>
|
||||
{% if key_form.public_key.errors %}
|
||||
<p class="mt-1 text-sm text-red-600">{{ key_form.public_key.errors|striptags }}</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% if key_form.non_field_errors %}
|
||||
<p class="text-sm text-red-600">{{ key_form.non_field_errors|striptags }}</p>
|
||||
{% endif %}
|
||||
<button type="submit" class="inline-flex items-center rounded-md bg-purple-600 px-4 py-2 text-sm font-semibold text-white shadow hover:bg-purple-700 focus:outline-none focus-visible:ring-2 focus-visible:ring-purple-600">
|
||||
Upload key
|
||||
</button>
|
||||
</form>
|
||||
{% else %}
|
||||
<p class="mt-4 text-sm text-gray-600">You do not have permission to add SSH keys.</p>
|
||||
{% endif %}
|
||||
|
||||
{% if ssh_keys %}
|
||||
<div class="mt-6 divide-y divide-gray-200">
|
||||
{% for key in ssh_keys %}
|
||||
<div class="flex items-center justify-between py-4">
|
||||
<div>
|
||||
<p class="text-sm font-semibold text-gray-900">{{ key.name }}</p>
|
||||
<p class="text-xs text-gray-500">{{ key.fingerprint }}</p>
|
||||
</div>
|
||||
<div class="flex items-center gap-3">
|
||||
{% if key.is_active %}
|
||||
<div class="inline-flex overflow-hidden rounded-md shadow-sm">
|
||||
<button
|
||||
type="button"
|
||||
class="inline-flex items-center rounded-l-md bg-purple-600 px-3 py-1.5 text-xs font-semibold text-white hover:bg-purple-700"
|
||||
data-download-url="/api/v1/keys/{{ key.id }}/certificate"
|
||||
>
|
||||
Download
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="inline-flex items-center rounded-r-md border border-l-0 border-gray-200 bg-gray-100 px-3 py-1.5 text-xs font-semibold text-gray-700 hover:bg-gray-200"
|
||||
data-download-url="/api/v1/keys/{{ key.id }}/certificate.sha256"
|
||||
>
|
||||
Hash
|
||||
</button>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
class="inline-flex items-center rounded-md bg-red-600 px-3 py-1.5 text-xs font-semibold text-white hover:bg-red-700 js-regenerate-cert"
|
||||
data-key-id="{{ key.id }}"
|
||||
>
|
||||
Regenerate
|
||||
</button>
|
||||
{% else %}
|
||||
<span class="text-xs font-semibold text-gray-500">Revoked</span>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% else %}
|
||||
<p class="mt-4 text-sm text-gray-600">No SSH keys uploaded yet.</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
<script>
|
||||
(function () {
|
||||
function getCookie(name) {
|
||||
var value = "; " + document.cookie;
|
||||
var parts = value.split("; " + name + "=");
|
||||
if (parts.length === 2) {
|
||||
return parts.pop().split(";").shift();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
function handleDownload(event) {
|
||||
var button = event.currentTarget;
|
||||
var url = button.getAttribute("data-download-url");
|
||||
if (!url) {
|
||||
return;
|
||||
}
|
||||
window.location.href = url;
|
||||
}
|
||||
|
||||
function handleRegenerate(event) {
|
||||
var button = event.currentTarget;
|
||||
var keyId = button.getAttribute("data-key-id");
|
||||
if (!keyId) {
|
||||
return;
|
||||
}
|
||||
if (!window.confirm("Regenerate the certificate for this key?")) {
|
||||
return;
|
||||
}
|
||||
var csrf = getCookie("csrftoken");
|
||||
fetch("/api/v1/keys/" + keyId + "/certificate", {
|
||||
method: "POST",
|
||||
credentials: "same-origin",
|
||||
headers: {
|
||||
"X-CSRFToken": csrf,
|
||||
},
|
||||
})
|
||||
.then(function (response) {
|
||||
if (!response.ok) {
|
||||
throw new Error("Certificate regeneration failed.");
|
||||
}
|
||||
window.location.href = "/api/v1/keys/" + keyId + "/certificate";
|
||||
})
|
||||
.catch(function (err) {
|
||||
window.alert(err.message);
|
||||
});
|
||||
}
|
||||
|
||||
var downloadButtons = document.querySelectorAll("[data-download-url]");
|
||||
for (var i = 0; i < downloadButtons.length; i += 1) {
|
||||
downloadButtons[i].addEventListener("click", handleDownload);
|
||||
}
|
||||
var buttons = document.querySelectorAll(".js-regenerate-cert");
|
||||
for (var j = 0; j < buttons.length; j += 1) {
|
||||
buttons[j].addEventListener("click", handleRegenerate);
|
||||
}
|
||||
})();
|
||||
</script>
|
||||
|
||||
<div class="mt-6 rounded-xl border border-gray-200 bg-white p-6 shadow-sm sm:p-8">
|
||||
<h2 class="text-base font-semibold tracking-tight text-gray-900">Data erasure request</h2>
|
||||
<p class="mt-2 text-sm text-gray-600">
|
||||
@@ -81,6 +227,7 @@
|
||||
{% if not erasure_request or erasure_request.status != "pending" %}
|
||||
<form method="post" class="mt-4 space-y-3">
|
||||
{% csrf_token %}
|
||||
<input type="hidden" name="form_type" value="erasure">
|
||||
<div>
|
||||
<label for="{{ erasure_form.reason.id_for_label }}" class="block text-sm font-medium text-gray-700">
|
||||
Reason for request
|
||||
|
||||
Reference in New Issue
Block a user