monkeysphere: Add key detail view

This commit is contained in:
James Valleroy 2016-02-14 15:45:30 -05:00 committed by Sunil Mohan Adapa
parent 18db38002b
commit 8c96d381e6
No known key found for this signature in database
GPG Key ID: 36C361440C9BC971
4 changed files with 100 additions and 1 deletions

View File

@ -63,7 +63,10 @@
<td>{{ domain.name }}</td>
<td>
{% if domain.key %}
{{ domain.key.pgp_fingerprint }}
<a href="{% url 'monkeysphere:details' domain.key.pgp_fingerprint %}"
title="Show details for key {{ domain.key.pgp_fingerprint }}">
{{ domain.key.pgp_fingerprint }}
</a>
{% else %}
{% trans "Not Available" %}
{% endif %}

View File

@ -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 <http://www.gnu.org/licenses/>.
#
{% endcomment %}
{% load bootstrap %}
{% load i18n %}
{% block content %}
<h2>{% trans "Monkeysphere" %}</h2>
<table class="table table-bordered table-condensed table-striped">
<tbody>
<tr>
<td>{% trans "OpenPGP Fingerprint" %}</td>
<td>{{ key.pgp_fingerprint }}</td>
</tr>
<tr>
<td>{% trans "OpenPGP Key ID" %}</td>
<td>{{ key.pub }}</td>
</tr>
<tr>
<td>{% trans "OpenPGP User ID" %}</td>
<td>{{ key.uid }}</td>
</tr>
<tr>
<td>{% trans "Key Generation Date" %}</td>
<td>{{ key.date }}</td>
</tr>
<tr>
<td>{% trans "SSH Key Type" %}</td>
<td>{{ key.ssh_key_type }}</td>
</tr>
<tr>
<td>{% trans "SSH Key Size" %}</td>
<td>{{ key.ssh_key_size }}</td>
</tr>
<tr>
<td>{% trans "SSH Fingerprint" %}</td>
<td>{{ key.ssh_fingerprint }}</td>
</tr>
</tbody>
</table>
<p>
{% blocktrans trimmed %}
After this key is published to the keyservers, it can be signed using
<a href="https://www.gnupg.org/">GnuPG</a> with the following commands:
{% endblocktrans %}
</p>
<pre>
{% 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 }}
</pre>
{% endblock %}

View File

@ -28,6 +28,8 @@ urlpatterns = [
url(r'^sys/monkeysphere/$', views.index, name='index'),
url(r'^sys/monkeysphere/(?P<domain>[^/]+)/generate/$',
views.generate, name='generate'),
url(r'^sys/monkeysphere/(?P<fingerprint>[0-9A-Fa-f]+)/details/$',
views.details, name='details'),
url(r'^sys/monkeysphere/(?P<fingerprint>[0-9A-Fa-f]+)/publish/$',
views.publish, name='publish'),
url(r'^sys/monkeysphere/cancel/$', views.cancel, name='cancel'),

View File

@ -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