From 8c96d381e6632750dc70162dce71638989346447 Mon Sep 17 00:00:00 2001 From: James Valleroy Date: Sun, 14 Feb 2016 15:45:30 -0500 Subject: [PATCH] monkeysphere: Add key detail view --- .../monkeysphere/templates/monkeysphere.html | 5 +- .../templates/monkeysphere_details.html | 76 +++++++++++++++++++ plinth/modules/monkeysphere/urls.py | 2 + plinth/modules/monkeysphere/views.py | 18 +++++ 4 files changed, 100 insertions(+), 1 deletion(-) create mode 100644 plinth/modules/monkeysphere/templates/monkeysphere_details.html diff --git a/plinth/modules/monkeysphere/templates/monkeysphere.html b/plinth/modules/monkeysphere/templates/monkeysphere.html index 58258c6c0..2244096f6 100644 --- a/plinth/modules/monkeysphere/templates/monkeysphere.html +++ b/plinth/modules/monkeysphere/templates/monkeysphere.html @@ -63,7 +63,10 @@ {{ domain.name }} {% if domain.key %} - {{ domain.key.pgp_fingerprint }} + + {{ domain.key.pgp_fingerprint }} + {% else %} {% trans "Not Available" %} {% endif %} diff --git a/plinth/modules/monkeysphere/templates/monkeysphere_details.html b/plinth/modules/monkeysphere/templates/monkeysphere_details.html new file mode 100644 index 000000000..6d0c2e197 --- /dev/null +++ b/plinth/modules/monkeysphere/templates/monkeysphere_details.html @@ -0,0 +1,76 @@ +{% extends "base.html" %} +{% comment %} +# +# This file is part of Plinth. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +{% endcomment %} + +{% load bootstrap %} +{% load i18n %} + +{% block content %} + +

{% trans "Monkeysphere" %}

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
{% trans "OpenPGP Fingerprint" %}{{ key.pgp_fingerprint }}
{% trans "OpenPGP Key ID" %}{{ key.pub }}
{% trans "OpenPGP User ID" %}{{ key.uid }}
{% trans "Key Generation Date" %}{{ key.date }}
{% trans "SSH Key Type" %}{{ key.ssh_key_type }}
{% trans "SSH Key Size" %}{{ key.ssh_key_size }}
{% trans "SSH Fingerprint" %}{{ key.ssh_fingerprint }}
+ +

+ {% blocktrans trimmed %} + After this key is published to the keyservers, it can be signed using + GnuPG with the following commands: + {% endblocktrans %} +

+
+    {% trans "# download the key" %}
+    gpg --recv-key {{ key.pgp_fingerprint }}
+    {% trans "# sign the key" %}
+    gpg --sign-key {{ key.pgp_fingerprint }}
+    {% trans "# send the key back to the keyservers" %}
+    gpg --send-key {{ key.pgp_fingerprint }}
+  
+ +{% endblock %} diff --git a/plinth/modules/monkeysphere/urls.py b/plinth/modules/monkeysphere/urls.py index 5d5e20dea..c80f16714 100644 --- a/plinth/modules/monkeysphere/urls.py +++ b/plinth/modules/monkeysphere/urls.py @@ -28,6 +28,8 @@ urlpatterns = [ url(r'^sys/monkeysphere/$', views.index, name='index'), url(r'^sys/monkeysphere/(?P[^/]+)/generate/$', views.generate, name='generate'), + url(r'^sys/monkeysphere/(?P[0-9A-Fa-f]+)/details/$', + views.details, name='details'), url(r'^sys/monkeysphere/(?P[0-9A-Fa-f]+)/publish/$', views.publish, name='publish'), url(r'^sys/monkeysphere/cancel/$', views.cancel, name='cancel'), diff --git a/plinth/modules/monkeysphere/views.py b/plinth/modules/monkeysphere/views.py index 012a198de..30160c54a 100644 --- a/plinth/modules/monkeysphere/views.py +++ b/plinth/modules/monkeysphere/views.py @@ -62,6 +62,13 @@ def generate(request, domain): return redirect(reverse_lazy('monkeysphere:index')) +def details(request, fingerprint): + """Get details for an OpenPGP key.""" + key = get_key(fingerprint) + return TemplateResponse(request, 'monkeysphere_details.html', + {'title': _('Monkeysphere'), 'key': key}) + + @require_POST def publish(request, fingerprint): """Publish OpenPGP key for SSH service.""" @@ -104,6 +111,17 @@ def get_status(): return {'domains': domains} +def get_key(fingerprint): + """Get key by fingerprint.""" + output = actions.superuser_run('monkeysphere', + ['host-show-keys', fingerprint]) + if output: + keys = json.loads(output)['keys'] + return keys[0] + + return None + + def _collect_publish_result(request): """Handle publish process completion.""" global publish_process