Files
FreedomBox/freedombox/modules/wireguard/templates/wireguard_auto_add_client.html
T
Sunil Mohan Adapa 8858774b35 wireguard: Fix issues with QR codes and config download
- Previous changes introduced a regression where QR codes and configuration
download stopped working. This is because of removal of private key from
session. Fix this.

- Provide the QR code and configuration download inline so that private key does
not have to stored in session.

- Provide separate QR code and configuration for each of the available
endpoints.

- Move the manual parameters into a separate table for each of the endpoints.
Make it look like this is only needed as the last option.

- Immediately add the client when the page is presented instead of additional
step (there is no use input needed).

- Tone down the warnings into simple text.

- Provide additional parameters in the manual configuration parameters tables to
make it easy to configure (based on the parameters configured on the WireGuard
app for Android). Use terminology that is used in app so that the fields can be
mapped easily by the user.

Tests:

- Functional tests work more reliably now.

- Clicking on the 'Add Client Automatically' creates the client successfully. A
new message is shown with client public key. The description looks good.

- Clicking on 'Download config file', 'Show QR code' and 'Show config
parameters' works. Downloaded configuration file works. QR code works too and
fills in expected parameters. Shown manual parameters are correct.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2026-10-06 06:59:46 -04:00

88 lines
3.0 KiB
HTML

{% extends "base.html" %}
{% comment %}
# SPDX-License-Identifier: AGPL-3.0-or-later
{% endcomment %}
{% load bootstrap %}
{% load i18n %}
{% load extras %}
{% block content %}
<h3>{{ title }}</h3>
<div class="alert alert-info alert-client-added">
{% trans "New client added with public key:" %} {{ client_pubkey }}
</div>
<p>
{% blocktrans trimmed %}
To configure the client app, download the configuration file (.conf) for
import, scan the QR code, or use the parameters to configure from
scratch. This information can't be shown again. Be sure to get it before
navigating away from this page. Keep this information confidential.
{% endblocktrans %}
</p>
{% for domain, domain_info in domains.items %}
<h4>{% trans "Using domain:" %} {{ domain }}</h4>
<div class="btn-toolbar">
<a download="wg-client.conf" href="data:text/plain;base64,{{ domain_info.config }}"
class="btn btn-default btn-download-config-file">
{% icon 'download' %}
{% trans "Download config file" %}
</a>
<button class="btn btn-default btn-show-qr-code" type="button"
data-bs-target="#qr-code-{{ domain_info.endpoint }}"
aria-expanded="false" data-bs-toggle="collapse"
aria-controls="qr-code-{{ domain_info.endpoint }}">
{% trans "Show QR code" %}
</button>
<button class="btn btn-default btn-show-config-parameters" type="button"
data-bs-target="#config-params-{{ domain_info.endpoint }}"
aria-expanded="false" data-bs-toggle="collapse"
aria-controls="config-params-{{ domain_info.endpoint }}">
{% trans "Show config parameters" %}
</button>
</div>
<div class="collapse" id="qr-code-{{ domain_info.endpoint }}">
<img src="data:image/svg+xml;base64,{{ domain_info.qr_code }}"></img>
</div>
<div class="collapse" id="config-params-{{ domain_info.endpoint }}">
<table class="table table-sm">
<tbody>
<tr>
<td>{% trans "Client Public Key" %}</td>
<td class="client-public-key">{{ client_pubkey }}</td>
</tr>
<tr>
<td>{% trans "Client Private Key" %}</td>
<td class="client-private-key">{{ client_privkey }}</td>
</tr>
<tr>
<td>{% trans "Client IP Address" %}</td>
<td>{{ next_ip }}</td>
</tr>
<tr>
<td>{% trans "Client DNS Server" %}</td>
<td>10.84.0.1</td>
</tr>
<tr>
<td>{% trans "Server/Peer Public Key" %}</td>
<td>{{ server_pubkey }}</td>
</tr>
<tr>
<td>{% trans "Server/Peer Endpoint" %}</td>
<td>{{ domain_info.endpoint }}</td>
</tr>
<tr>
<td>{% trans "Server/Peer Allowed IPs" %}</td>
<td>0.0.0.0/0,::0/0</td>
</tr>
</tbody>
</table>
</div>
{% endfor %}
{% endblock %}