mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-07-22 11:59:33 +00:00
wireguard: Encode public keys for use in URLs
Signed-off-by: James Valleroy <jvalleroy@mailbox.org> Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
parent
64165c5fbd
commit
6b39aa8075
@ -37,13 +37,13 @@
|
||||
{% for peer in server_peers %}
|
||||
<tr>
|
||||
<td>
|
||||
<a href="{% url 'wireguard:show-client' peer.public_key %}">
|
||||
<a href="{% url 'wireguard:show-client' peer.public_key|urlencode:'' %}">
|
||||
{{ peer.public_key }}
|
||||
</a>
|
||||
</td>
|
||||
<td>{{ peer.latest_handshake }}</td>
|
||||
<td><a class="btn btn-sm btn-default"
|
||||
href="{% url 'wireguard:delete-client' peer.public_key %}">
|
||||
href="{% url 'wireguard:delete-client' peer.public_key|urlencode:'' %}">
|
||||
<span class="fa fa-trash-o" aria-hidden="true">
|
||||
</span>
|
||||
</td>
|
||||
@ -83,7 +83,7 @@
|
||||
<tr>
|
||||
<td>{{ peer.endpoint }}</td>
|
||||
<td>
|
||||
<a href="{% url 'wireguard:show-server' peer.public_key %}">
|
||||
<a href="{% url 'wireguard:show-server' peer.public_key|urlencode:'' %}">
|
||||
{{ peer.public_key }}
|
||||
</a>
|
||||
</td>
|
||||
|
||||
@ -18,6 +18,8 @@
|
||||
Views for WireGuard application.
|
||||
"""
|
||||
|
||||
import urllib.parse
|
||||
|
||||
from django.contrib import messages
|
||||
from django.contrib.messages.views import SuccessMessageMixin
|
||||
from django.shortcuts import redirect
|
||||
@ -82,7 +84,7 @@ class ShowClientView(SuccessMessageMixin, TemplateView):
|
||||
context = super().get_context_data(**kwargs)
|
||||
context['title'] = _('Show Client')
|
||||
|
||||
public_key = self.kwargs['public_key']
|
||||
public_key = urllib.parse.unquote(self.kwargs['public_key'])
|
||||
info = wireguard.get_info()
|
||||
context.update(info)
|
||||
for client in info['my_server']['clients']:
|
||||
@ -100,11 +102,12 @@ class DeleteClientView(SuccessMessageMixin, TemplateView):
|
||||
"""Return additional context data for rendering the template."""
|
||||
context = super().get_context_data(**kwargs)
|
||||
context['title'] = _('Delete Client')
|
||||
context['public_key'] = self.kwargs['public_key']
|
||||
context['public_key'] = urllib.parse.unquote(self.kwargs['public_key'])
|
||||
return context
|
||||
|
||||
def post(self, request, public_key):
|
||||
"""Delete the client."""
|
||||
public_key = urllib.parse.unquote(public_key)
|
||||
actions.superuser_run('wireguard', ['remove-client', public_key])
|
||||
messages.success(request, _('Client deleted.'))
|
||||
return redirect('wireguard:index')
|
||||
@ -152,7 +155,7 @@ class ShowServerView(SuccessMessageMixin, TemplateView):
|
||||
context = super().get_context_data(**kwargs)
|
||||
context['title'] = _('Show Server')
|
||||
|
||||
public_key = self.kwargs['public_key']
|
||||
public_key = urllib.parse.unquote(self.kwargs['public_key'])
|
||||
info = wireguard.get_info()
|
||||
context.update(info)
|
||||
for server in info['my_client']['servers']:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user