mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-11-29 08:25:10 +00:00
monkeysphere: Drop app as it is not being used
Closes #2157. Signed-off-by: Joseph Nuthalapati <njoseph@riseup.net> [sunil: Split diaspora and tahoe-lafs into separate commits] [sunil: Remove monkeysphere from help/tests/test_views.py] [sunil: Add to configuration file removal in Debian package and setup.py] Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
1 parent
f72505d300
commit
ce5274d9ee
16 files changed
+15
-916
No files matched your search
@@ -109,17 +109,16 @@ MANUAL_PAGES = ('Apache_userdir', 'APU', 'Backups', 'BananaPro', 'BeagleBone',
|
||||
'freedombox-manual', 'GettingHelp', 'GitWeb', 'Hardware',
|
||||
'I2P', 'Ikiwiki', 'Infinoted', 'Introduction', 'JSXC',
|
||||
'LetsEncrypt', 'Maker', 'MatrixSynapse', 'MediaWiki',
|
||||
'Minetest', 'MiniDLNA', 'MLDonkey', 'Monkeysphere', 'Mumble',
|
||||
'NameServices', 'Networks', 'OpenVPN', 'OrangePiZero',
|
||||
'PageKite', 'pcDuino3', 'Performance', 'PineA64+',
|
||||
'PioneerEdition', 'Plinth', 'Power', 'Privoxy', 'Quassel',
|
||||
'QuickStart', 'Radicale', 'RaspberryPi2', 'RaspberryPi3B+',
|
||||
'RaspberryPi3B', 'RaspberryPi4B', 'ReleaseNotes', 'Rock64',
|
||||
'RockPro64', 'Roundcube', 'Samba', 'Searx', 'SecureShell',
|
||||
'Security', 'ServiceDiscovery', 'Shadowsocks', 'Sharing',
|
||||
'Snapshots', 'Storage', 'Syncthing', 'TinyTinyRSS', 'Tor',
|
||||
'Transmission', 'Upgrades', 'USBWiFi', 'Users', 'VirtualBox',
|
||||
'WireGuard')
|
||||
'Minetest', 'MiniDLNA', 'MLDonkey', 'Mumble', 'NameServices',
|
||||
'Networks', 'OpenVPN', 'OrangePiZero', 'PageKite', 'pcDuino3',
|
||||
'Performance', 'PineA64+', 'PioneerEdition', 'Plinth', 'Power',
|
||||
'Privoxy', 'Quassel', 'QuickStart', 'Radicale', 'RaspberryPi2',
|
||||
'RaspberryPi3B+', 'RaspberryPi3B', 'RaspberryPi4B',
|
||||
'ReleaseNotes', 'Rock64', 'RockPro64', 'Roundcube', 'Samba',
|
||||
'Searx', 'SecureShell', 'Security', 'ServiceDiscovery',
|
||||
'Shadowsocks', 'Sharing', 'Snapshots', 'Storage', 'Syncthing',
|
||||
'TinyTinyRSS', 'Tor', 'Transmission', 'Upgrades', 'USBWiFi',
|
||||
'Users', 'VirtualBox', 'WireGuard')
|
||||
_restricted_reason = ('Needs installed manual. '
|
||||
'CI speed-optimized workspace does not provide it.')
|
||||
not_restricted_environment = pytest.mark.skipif(not canary.exists(),
|
||||
|
||||
@@ -1,74 +0,0 @@
|
||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
"""
|
||||
FreedomBox app for monkeysphere.
|
||||
"""
|
||||
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from plinth import app as app_module
|
||||
from plinth import menu
|
||||
from plinth.modules.backups.components import BackupRestore
|
||||
from plinth.modules.users.components import UsersAndGroups
|
||||
from plinth.package import Packages
|
||||
|
||||
from . import manifest
|
||||
|
||||
_description = [
|
||||
_('With Monkeysphere, an OpenPGP key can be generated for each configured '
|
||||
'domain serving SSH. The OpenPGP public key can then be uploaded to the '
|
||||
'OpenPGP keyservers. Users connecting to this machine through SSH can '
|
||||
'verify that they are connecting to the correct host. For users to '
|
||||
'trust the key, at least one person (usually the machine owner) must '
|
||||
'sign the key using the regular OpenPGP key signing process. See the '
|
||||
'<a href="http://web.monkeysphere.info/getting-started-ssh/"> '
|
||||
'Monkeysphere SSH documentation</a> for more details.'),
|
||||
_('Monkeysphere can also generate an OpenPGP key for each Secure Web '
|
||||
'Server (HTTPS) certificate installed on this machine. The OpenPGP '
|
||||
'public key can then be uploaded to the OpenPGP keyservers. Users '
|
||||
'accessing the web server through HTTPS can verify that they are '
|
||||
'connecting to the correct host. To validate the certificate, the user '
|
||||
'will need to install some software that is available on the '
|
||||
'<a href="https://web.monkeysphere.info/download/"> Monkeysphere '
|
||||
'website</a>.')
|
||||
]
|
||||
|
||||
app = None
|
||||
|
||||
|
||||
class MonkeysphereApp(app_module.App):
|
||||
"""FreedomBox app for Monkeysphere."""
|
||||
|
||||
app_id = 'monkeysphere'
|
||||
|
||||
_version = 1
|
||||
|
||||
def __init__(self):
|
||||
"""Create components for the app."""
|
||||
super().__init__()
|
||||
|
||||
info = app_module.Info(app_id=self.app_id, version=self._version,
|
||||
name=_('Monkeysphere'), icon='fa-certificate',
|
||||
description=_description,
|
||||
manual_page='Monkeysphere')
|
||||
self.add(info)
|
||||
|
||||
menu_item = menu.Menu('menu-monkeysphere', info.name, None, info.icon,
|
||||
'monkeysphere:index', parent_url_name='system',
|
||||
advanced=True)
|
||||
self.add(menu_item)
|
||||
|
||||
packages = Packages('packages-monkeysphere', ['monkeysphere'])
|
||||
self.add(packages)
|
||||
|
||||
users_and_groups = UsersAndGroups('users-and-groups-monkeysphere',
|
||||
reserved_usernames=['monkeysphere'])
|
||||
self.add(users_and_groups)
|
||||
|
||||
backup_restore = BackupRestore('backup-restore-monkeysphere',
|
||||
**manifest.backup)
|
||||
self.add(backup_restore)
|
||||
|
||||
|
||||
def setup(helper, old_version=None):
|
||||
"""Install and configure the module."""
|
||||
app.setup(old_version)
|
||||
@@ -1 +0,0 @@
|
||||
plinth.modules.monkeysphere
|
||||
@@ -1,13 +0,0 @@
|
||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
"""
|
||||
Application manfiest for monkeysphere.
|
||||
"""
|
||||
|
||||
backup = {
|
||||
'config': {
|
||||
'directories': ['/etc/monkeysphere/']
|
||||
},
|
||||
'secrets': {
|
||||
'directories': ['/var/lib/monkeysphere/']
|
||||
}
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
/*
|
||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
td li {
|
||||
list-style: none;
|
||||
line-height: 2rem;
|
||||
}
|
||||
|
||||
td ul {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.form-action.pull-right {
|
||||
margin-right: 0.625rem;
|
||||
}
|
||||
|
||||
.form-action button {
|
||||
width: 7.875rem;
|
||||
}
|
||||
@@ -1,136 +0,0 @@
|
||||
{% extends "app.html" %}
|
||||
{% comment %}
|
||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
{% endcomment %}
|
||||
|
||||
{% load bootstrap %}
|
||||
{% load i18n %}
|
||||
{% load static %}
|
||||
|
||||
{% block page_head %}
|
||||
<link type="text/css" rel="stylesheet"
|
||||
href="{% static 'monkeysphere/monkeysphere.css' %}"/>
|
||||
{% endblock %}
|
||||
|
||||
{% block configuration %}
|
||||
|
||||
{% if running %}
|
||||
<p class="running-status-parent">
|
||||
<span class="running-status loading"></span>
|
||||
{% trans "Publishing key to keyserver..." %}
|
||||
|
||||
<form class="form" method="post"
|
||||
action="{% url 'monkeysphere:cancel' %}">
|
||||
{% csrf_token %}
|
||||
|
||||
<button type="submit" class="btn btn-warning btn-sm">
|
||||
{% trans "Cancel" %}</button>
|
||||
</form>
|
||||
</p>
|
||||
{% endif %}
|
||||
|
||||
<div class="table-responsive">
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{% trans "Service" %}</th>
|
||||
<th>{% trans "Domains" %}</th>
|
||||
<th>{% trans "OpenPGP Fingerprint" %}</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for key in status.keys.values|dictsort:"ssh_fingerprint" %}
|
||||
<tr class="monkeysphere-service-{{ key.service }}">
|
||||
<td>
|
||||
{% if key.service == 'ssh' %}
|
||||
{% trans "Secure Shell" %}
|
||||
{% elif key.service == 'https' %}
|
||||
{% trans "Web Server" %}
|
||||
{% else %}
|
||||
{% trans "Other" %}
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>
|
||||
<ul>
|
||||
{% for domain in key.all_domains %}
|
||||
{% if domain not in key.imported_domains %}
|
||||
<li>
|
||||
<span class="badge badge-secondary"
|
||||
><span class="fa fa-times"
|
||||
aria-hidden="true"></span></span>
|
||||
<span class="monkeysphere-importable-domain"
|
||||
>{{ domain }}</span>
|
||||
</li>
|
||||
{% elif domain not in key.available_domains %}
|
||||
<li>
|
||||
<span class="badge badge-warning"
|
||||
><span class="fa fa-exclamation-triangle"
|
||||
aria-hidden="true"></span></span>
|
||||
<span class="monkeysphere-unavailable-domain"
|
||||
>{{ domain }}</span>
|
||||
</li>
|
||||
{% else %}
|
||||
<li>
|
||||
<span class="badge badge-success"
|
||||
><span class="fa fa-check"
|
||||
aria-hidden="true"></span></span>
|
||||
<span class="monkeysphere-imported-domain"
|
||||
>{{ domain }}</span>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</td>
|
||||
<td>
|
||||
{% if key.openpgp_fingerprint %}
|
||||
<a href="{% url 'monkeysphere:details' key.openpgp_fingerprint %}"
|
||||
title="{% blocktrans trimmed with fingerprint=key.openpgp_fingerprint %}
|
||||
Show details for key {{ fingerprint }}
|
||||
{% endblocktrans %}">
|
||||
{{ key.openpgp_fingerprint }}
|
||||
</a>
|
||||
{% else %}
|
||||
{% trans "-" %}
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>
|
||||
{% if not key.openpgp_fingerprint %}
|
||||
<form class="form pull-right form-action form-import"
|
||||
method="post"
|
||||
action="{% url 'monkeysphere:import' key.ssh_fingerprint %}">
|
||||
{% csrf_token %}
|
||||
|
||||
<button type="submit" class="btn btn-primary btn-sm pull-right button-import">
|
||||
{% trans "Import Key" %}</button>
|
||||
</form>
|
||||
{% else %}
|
||||
{% if not running %}
|
||||
<form class="form pull-right form-action form-publish"
|
||||
method="post"
|
||||
action="{% url 'monkeysphere:publish' key.openpgp_fingerprint %}">
|
||||
{% csrf_token %}
|
||||
|
||||
<button type="submit" class="btn btn-warning btn-sm pull-right button-publish">
|
||||
{% trans "Publish Key" %}</button>
|
||||
</form>
|
||||
{% endif %}
|
||||
{% if key.importable_domains %}
|
||||
<form class="form pull-right form-action form-add-domain"
|
||||
method="post"
|
||||
action="{% url 'monkeysphere:import' key.ssh_fingerprint %}">
|
||||
{% csrf_token %}
|
||||
|
||||
<button type="submit" class="btn btn-primary btn-sm pull-right button-add-domains">
|
||||
{% trans "Add Domains" %}</button>
|
||||
</form>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
||||
@@ -1,85 +0,0 @@
|
||||
{% extends "base.html" %}
|
||||
{% comment %}
|
||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
{% endcomment %}
|
||||
|
||||
{% load bootstrap %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
<h2>{% trans "Monkeysphere" %}</h2>
|
||||
|
||||
<div class="table-responsive">
|
||||
<table class="table">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>{% trans "OpenPGP Fingerprint" %}</td>
|
||||
<td>{{ key.openpgp_fingerprint }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>{% trans "OpenPGP User IDs" %}</td>
|
||||
<td>{{ key.uids|join:', ' }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>{% trans "Key Import 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>
|
||||
<tr>
|
||||
<td>{% trans "Service" %}</td>
|
||||
<td>
|
||||
{% if key.service == 'ssh' %}
|
||||
{% trans "Secure Shell" %}
|
||||
{% elif key.service == 'https' %}
|
||||
{% trans "Web Server" %}
|
||||
{% else %}
|
||||
{% trans "Other" %}
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>{% trans "Key File" %}</td>
|
||||
<td>{{ key.key_file }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>{% trans "Available Domains" %}</td>
|
||||
<td>{{ key.available_domains|join:', ' }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>{% trans "Added Domains" %}</td>
|
||||
<td>{{ key.imported_domains|join:', ' }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<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.openpgp_fingerprint }}
|
||||
|
||||
# {% trans "Sign the key" %}
|
||||
gpg --sign-key {{ key.openpgp_fingerprint }}
|
||||
|
||||
# {% trans "Send the key back to the keyservers" %}
|
||||
gpg --send-key {{ key.openpgp_fingerprint }}
|
||||
</pre>
|
||||
|
||||
{% endblock %}
|
||||
Whitespace-only changes.
@@ -1,100 +0,0 @@
|
||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
"""
|
||||
Functional, browser based tests for monkeysphere app.
|
||||
"""
|
||||
|
||||
import pytest
|
||||
from plinth.tests import functional
|
||||
|
||||
pytestmark = [pytest.mark.system, pytest.mark.monkeysphere]
|
||||
|
||||
|
||||
@pytest.fixture(scope='module', autouse=True)
|
||||
def fixture_background(session_browser):
|
||||
"""Login and install the app."""
|
||||
functional.login(session_browser)
|
||||
functional.set_advanced_mode(session_browser, True)
|
||||
functional.install(session_browser, 'monkeysphere')
|
||||
functional.set_domain_name(session_browser, 'mydomain.example')
|
||||
yield
|
||||
|
||||
|
||||
def test_import_ssh_keys(session_browser):
|
||||
"""Test importing SSH keys."""
|
||||
_import_key(session_browser, 'ssh', 'mydomain.example')
|
||||
_assert_imported_key(session_browser, 'ssh', 'mydomain.example')
|
||||
|
||||
|
||||
def test_import_https_keys(session_browser):
|
||||
"""Test importing HTTPS keys."""
|
||||
_import_key(session_browser, 'https', 'mydomain.example')
|
||||
_assert_imported_key(session_browser, 'https', 'mydomain.example')
|
||||
|
||||
|
||||
def test_publish_ssh_keys(session_browser):
|
||||
"""Test publishing SSH keys."""
|
||||
_import_key(session_browser, 'ssh', 'mydomain.example')
|
||||
_publish_key(session_browser, 'ssh', 'mydomain.example')
|
||||
|
||||
|
||||
def test_publish_https_keys(session_browser):
|
||||
"""Test publishing HTTPS keys."""
|
||||
_import_key(session_browser, 'https', 'mydomain.example')
|
||||
_publish_key(session_browser, 'https', 'mydomain.example')
|
||||
|
||||
|
||||
def test_backup_restore(session_browser):
|
||||
"""Test backup and restore of keys"""
|
||||
_import_key(session_browser, 'ssh', 'mydomain.example')
|
||||
_import_key(session_browser, 'https', 'mydomain.example')
|
||||
functional.backup_create(session_browser, 'monkeysphere',
|
||||
'test_monkeysphere')
|
||||
|
||||
functional.backup_restore(session_browser, 'monkeysphere',
|
||||
'test_monkeysphere')
|
||||
_assert_imported_key(session_browser, 'ssh', 'mydomain.example')
|
||||
_assert_imported_key(session_browser, 'https', 'mydomain.example')
|
||||
|
||||
|
||||
def _find_domain(browser, key_type, domain_type, domain):
|
||||
"""Iterate every domain of a given type which given key type."""
|
||||
keys_of_type = browser.find_by_css(
|
||||
'.monkeysphere-service-{}'.format(key_type))
|
||||
for key_of_type in keys_of_type:
|
||||
search_domains = key_of_type.find_by_css(
|
||||
'.monkeysphere-{}-domain'.format(domain_type))
|
||||
for search_domain in search_domains:
|
||||
if search_domain.text == domain:
|
||||
return key_of_type, search_domain
|
||||
|
||||
raise IndexError('Domain not found')
|
||||
|
||||
|
||||
def _import_key(browser, key_type, domain):
|
||||
"""Import a key of specified type for given domain into monkeysphere."""
|
||||
try:
|
||||
_assert_imported_key(browser, key_type, domain)
|
||||
except IndexError:
|
||||
pass
|
||||
else:
|
||||
return
|
||||
|
||||
key, _ = _find_domain(browser, key_type, 'importable', domain)
|
||||
with functional.wait_for_page_update(browser):
|
||||
key.find_by_css('.button-import').click()
|
||||
|
||||
|
||||
def _assert_imported_key(browser, key_type, domain):
|
||||
"""Assert that a key of specified type for given domain was imported.."""
|
||||
functional.nav_to_module(browser, 'monkeysphere')
|
||||
return _find_domain(browser, key_type, 'imported', domain)
|
||||
|
||||
|
||||
def _publish_key(browser, key_type, domain):
|
||||
"""Publish a key of specified type for given domain from monkeysphere."""
|
||||
functional.nav_to_module(browser, 'monkeysphere')
|
||||
key, _ = _find_domain(browser, key_type, 'imported', domain)
|
||||
with functional.wait_for_page_update(browser):
|
||||
key.find_by_css('.button-publish').click()
|
||||
|
||||
functional.wait_for_config_update(browser, 'monkeysphere')
|
||||
@@ -1,19 +0,0 @@
|
||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
"""
|
||||
URLs for the monkeysphere module.
|
||||
"""
|
||||
|
||||
from django.urls import re_path
|
||||
|
||||
from . import views
|
||||
|
||||
urlpatterns = [
|
||||
re_path(r'^sys/monkeysphere/$', views.index, name='index'),
|
||||
re_path(r'^sys/monkeysphere/(?P<ssh_fingerprint>[0-9A-Za-z:+/]+)/import/$',
|
||||
views.import_key, name='import'),
|
||||
re_path(r'^sys/monkeysphere/(?P<fingerprint>[0-9A-Fa-f]+)/details/$',
|
||||
views.details, name='details'),
|
||||
re_path(r'^sys/monkeysphere/(?P<fingerprint>[0-9A-Fa-f]+)/publish/$',
|
||||
views.publish, name='publish'),
|
||||
re_path(r'^sys/monkeysphere/cancel/$', views.cancel, name='cancel'),
|
||||
]
|
||||
@@ -1,135 +0,0 @@
|
||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
"""
|
||||
Views for the monkeysphere module.
|
||||
"""
|
||||
|
||||
import json
|
||||
|
||||
from django.contrib import messages
|
||||
from django.shortcuts import redirect
|
||||
from django.template.response import TemplateResponse
|
||||
from django.urls import reverse_lazy
|
||||
from django.utils.translation import gettext as _
|
||||
from django.views.decorators.http import require_POST
|
||||
|
||||
from plinth import actions
|
||||
from plinth.modules import monkeysphere, names
|
||||
|
||||
publish_process = None
|
||||
|
||||
|
||||
def index(request):
|
||||
"""Serve configuration page."""
|
||||
_collect_publish_result(request)
|
||||
status = get_status()
|
||||
return TemplateResponse(
|
||||
request, 'monkeysphere.html', {
|
||||
'app_info': monkeysphere.app.info,
|
||||
'title': monkeysphere.app.info.name,
|
||||
'status': status,
|
||||
'running': bool(publish_process),
|
||||
'refresh_page_sec': 3 if bool(publish_process) else None,
|
||||
})
|
||||
|
||||
|
||||
@require_POST
|
||||
def import_key(request, ssh_fingerprint):
|
||||
"""Import a key into monkeysphere."""
|
||||
keys = get_keys()
|
||||
available_domains = keys[ssh_fingerprint]['available_domains']
|
||||
try:
|
||||
actions.superuser_run('monkeysphere',
|
||||
['host-import-key', ssh_fingerprint] +
|
||||
list(available_domains))
|
||||
messages.success(request, _('Imported key.'))
|
||||
except actions.ActionError as exception:
|
||||
messages.error(request, str(exception))
|
||||
|
||||
return redirect(reverse_lazy('monkeysphere:index'))
|
||||
|
||||
|
||||
def details(request, fingerprint):
|
||||
"""Get details for an OpenPGP key."""
|
||||
return TemplateResponse(request, 'monkeysphere_details.html', {
|
||||
'title': monkeysphere.app.info.name,
|
||||
'key': get_key(fingerprint)
|
||||
})
|
||||
|
||||
|
||||
@require_POST
|
||||
def publish(request, fingerprint):
|
||||
"""Publish OpenPGP key for SSH service."""
|
||||
global publish_process
|
||||
if not publish_process:
|
||||
publish_process = actions.superuser_run(
|
||||
'monkeysphere', ['host-publish-key', fingerprint],
|
||||
run_in_background=True)
|
||||
|
||||
return redirect(reverse_lazy('monkeysphere:index'))
|
||||
|
||||
|
||||
@require_POST
|
||||
def cancel(request):
|
||||
"""Cancel ongoing process."""
|
||||
global publish_process
|
||||
if publish_process:
|
||||
actions.superuser_run(
|
||||
'monkeysphere', ['host-cancel-publish',
|
||||
str(publish_process.pid)])
|
||||
publish_process = None
|
||||
messages.info(request, _('Cancelled key publishing.'))
|
||||
|
||||
return redirect(reverse_lazy('monkeysphere:index'))
|
||||
|
||||
|
||||
def get_status():
|
||||
"""Get the current status."""
|
||||
return {'keys': get_keys()}
|
||||
|
||||
|
||||
def get_keys(fingerprint=None):
|
||||
"""Get keys."""
|
||||
fingerprint = [fingerprint] if fingerprint else []
|
||||
output = actions.superuser_run('monkeysphere',
|
||||
['host-show-keys'] + fingerprint)
|
||||
keys = json.loads(output)['keys']
|
||||
|
||||
domains = names.components.DomainName.list_names()
|
||||
for key in keys.values():
|
||||
key['imported_domains'] = set(key.get('imported_domains', []))
|
||||
key['available_domains'] = set(key.get('available_domains', []))
|
||||
if '*' in key['available_domains']:
|
||||
key['available_domains'] = set(domains)
|
||||
|
||||
key['all_domains'] = sorted(key['available_domains'].union(
|
||||
key['imported_domains']))
|
||||
key['importable_domains'] = key['available_domains'] \
|
||||
.difference(key['imported_domains'])
|
||||
|
||||
return keys
|
||||
|
||||
|
||||
def get_key(fingerprint):
|
||||
"""Get key by fingerprint."""
|
||||
keys = get_keys(fingerprint)
|
||||
return list(keys.values())[0] if len(keys) else None
|
||||
|
||||
|
||||
def _collect_publish_result(request):
|
||||
"""Handle publish process completion."""
|
||||
global publish_process
|
||||
if not publish_process:
|
||||
return
|
||||
|
||||
return_code = publish_process.poll()
|
||||
|
||||
# Publish process is not complete yet
|
||||
if return_code is None:
|
||||
return
|
||||
|
||||
if not return_code:
|
||||
messages.success(request, _('Published key to keyserver.'))
|
||||
else:
|
||||
messages.error(request, _('Error occurred while publishing key.'))
|
||||
|
||||
publish_process = None
|
||||
Reference in new issue
Block a user