mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-05-27 10:44:33 +00:00
openvpn: Allow non-admin users to download their own profiles
- This adds OpenVPN icon - This enables the OpenVPN app on the index page. - This allows only admins to create the certs for OpenVPN and admins and non admins can not download their own profiles via the app icon.
This commit is contained in:
parent
40ceb9a152
commit
b0321d7d29
1
LICENSES
1
LICENSES
@ -57,3 +57,4 @@ otherwise.
|
||||
- static/themes/default/icons/transmission.png :: [[https://transmissionbt.com/][GPL]]
|
||||
- static/themes/default/icons/ttrss.png :: [[https://tt-rss.org/gitlab/fox/tt-rss][GPL]]
|
||||
- static/themes/default/icons/xmpp.png :: [[https://www.ejabberd.im/][GPL3]]
|
||||
- static/themes/default/icons/openvpn.png :: [[https://github.com/thekishanraval/Logos][GPLv3]]
|
||||
|
||||
@ -18,12 +18,13 @@
|
||||
"""
|
||||
Plinth module to configure OpenVPN server.
|
||||
"""
|
||||
|
||||
from django.urls import reverse_lazy
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from plinth import actions
|
||||
from plinth import action_utils
|
||||
from plinth import cfg
|
||||
from plinth import frontpage
|
||||
from plinth import service as service_module
|
||||
from plinth.utils import format_lazy
|
||||
|
||||
@ -53,7 +54,8 @@ description = [
|
||||
|
||||
|
||||
def init():
|
||||
"""Intialize the OpenVPN module."""
|
||||
"""Initialize the OpenVPN module."""
|
||||
|
||||
menu = cfg.main_menu.get('apps:index')
|
||||
menu.add_urlname(title, 'glyphicon-lock', 'openvpn:index')
|
||||
|
||||
@ -63,14 +65,34 @@ def init():
|
||||
service = service_module.Service(
|
||||
managed_services[0], title, ports=['openvpn'], is_external=True)
|
||||
|
||||
print(is_setup())
|
||||
if is_enabled() and is_setup():
|
||||
add_shortcut()
|
||||
|
||||
|
||||
def is_enabled():
|
||||
return action_utils.service_is_enabled('openvpn')
|
||||
|
||||
|
||||
def setup(helper, old_version=None):
|
||||
"""Install and configure the module."""
|
||||
|
||||
helper.install(managed_packages)
|
||||
global service
|
||||
if service is None:
|
||||
service = service_module.Service(
|
||||
managed_services[0], title, ports=['openvpn'], is_external=True)
|
||||
add_shortcut()
|
||||
|
||||
|
||||
def add_shortcut():
|
||||
frontpage.add_shortcut('openvpn', title,
|
||||
details=description + [
|
||||
'<a class="btn btn-primary btn-sm"'
|
||||
'href="/plinth/apps/openvpn/profile">Download Profile</a>'
|
||||
],
|
||||
configure_url=reverse_lazy('openvpn:index'),
|
||||
login_required=True)
|
||||
|
||||
|
||||
def is_setup():
|
||||
@ -80,8 +102,4 @@ def is_setup():
|
||||
|
||||
def diagnose():
|
||||
"""Run diagnostics and return the results."""
|
||||
results = []
|
||||
|
||||
results.append(action_utils.diagnose_port_listening(1194, 'udp4'))
|
||||
|
||||
return results
|
||||
return [action_utils.diagnose_port_listening(1194, 'udp4')]
|
||||
|
||||
@ -21,11 +21,12 @@ URLs for the OpenVPN module.
|
||||
|
||||
from django.conf.urls import url
|
||||
|
||||
from plinth.utils import non_admin_view
|
||||
from . import views
|
||||
|
||||
|
||||
urlpatterns = [
|
||||
url(r'^apps/openvpn/$', views.index, name='index'),
|
||||
url(r'^apps/openvpn/setup/$', views.setup, name='setup'),
|
||||
url(r'^apps/openvpn/profile/$', views.profile, name='profile'),
|
||||
url(r'^apps/openvpn/profile/$', non_admin_view(views.profile), name='profile'),
|
||||
]
|
||||
|
||||
@ -75,7 +75,6 @@ def setup(request):
|
||||
return redirect('openvpn:index')
|
||||
|
||||
|
||||
@require_POST
|
||||
def profile(request):
|
||||
"""Provide the user's profile for download."""
|
||||
username = request.user.username
|
||||
@ -97,14 +96,13 @@ def profile(request):
|
||||
|
||||
def get_status():
|
||||
"""Get the current settings from OpenVPN server."""
|
||||
status = {'is_setup': openvpn.is_setup(),
|
||||
'setup_running': False,
|
||||
'enabled': openvpn.service.is_enabled(),
|
||||
'is_running': openvpn.service.is_running()}
|
||||
|
||||
status['setup_running'] = bool(setup_process)
|
||||
|
||||
return status
|
||||
return {
|
||||
'is_setup': openvpn.is_setup(),
|
||||
'setup_running': bool(setup_process),
|
||||
'enabled': openvpn.service.is_enabled(),
|
||||
'is_running': openvpn.service.is_running()
|
||||
}
|
||||
|
||||
|
||||
def _collect_setup_result(request):
|
||||
|
||||
BIN
static/themes/default/icons/openvpn.png
Normal file
BIN
static/themes/default/icons/openvpn.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 31 KiB |
Loading…
x
Reference in New Issue
Block a user