mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-09-19 04:59:01 +00:00
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
35 lines
920 B
Python
35 lines
920 B
Python
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
"""FreedomBox app for configuring OpenVPN server."""
|
|
|
|
import logging
|
|
|
|
from django.http import HttpResponse
|
|
|
|
from freedombox.modules.names.components import DomainName
|
|
from freedombox.views import AppView
|
|
|
|
from . import privileged
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
class OpenVPNAppView(AppView):
|
|
"""Show OpenVPN app main page."""
|
|
|
|
app_id = 'openvpn'
|
|
template_name = 'openvpn.html'
|
|
|
|
|
|
def profile(request):
|
|
"""Provide the user's profile for download."""
|
|
username = request.user.username
|
|
domain_name = DomainName.list_names()[0]
|
|
|
|
profile_string = privileged.get_profile(username, domain_name)
|
|
response = HttpResponse(profile_string,
|
|
content_type='application/x-openvpn-profile')
|
|
response['Content-Disposition'] = \
|
|
'attachment; filename={username}.ovpn'.format(username=username)
|
|
|
|
return response
|