Tests:
- Visit the URL /freedombox/apache/discover-idp/?method=<i>blah</i>. The shown
HTML error message escapes the HTML properly with the patch and doesn't without.
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
- Store the names locally in FreedomBox interface as Network Manager does not
support adding a name to a client.
- Auto-generate names for ones that currently don't have names and when
auto-adding a client.
- Allow editing the client name on edit page and manual add page.
- Show name in:
- WireGuard page
- Add client page.
- Auto-add client page.
- Delete client page.
- Show client page.
- Link to show client page from name instead of public key in WireGuard.
- Add Edit/Delete buttons in auto-add client page.
- Style delete client page differently.
- Forget all client names when app is uninstalled.
Tests:
- Unit and functional tests work.
- When editing a client, name field is shown. Changing the name works. Changing
the public key and name also works.
- When adding a client manually, name field is shown. Setting a default name
works. Setting a non-default name works.
- On the WireGuard main page, name of client is shown and has link to show
client page. Links works. There is no link on the pubic key.
- When adding a client manually, the name is shown at the top of the page along
with the name field at the bottom.
- When auto-adding a client. Name is shown in the success notice message. Edit
and delete buttons are shown and they work.
- On delete client page, information is shown as table. Name and public key are
shown.
- On show client page, name of the client is shown.
- When clients are added without the patches and patches are applied, when
viewing WireGuard page, all existing clients are given a name automatically.
- After app is uninstalled, the freedombox sqlite3 database does not contain the
key 'wireguard_client_names' in 'freedombox_kvstore' table. Uninstalling without
any clients does not lead to an error.
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
- Update the tooltip too.
Tests:
- In the WireGuard page, the two buttons and tooltips have been updated.
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
- When routing traffic through FreedomBox via WireGuard, the bind app acts as a
DNS server. Otherwise, the client can't resolve domains into IP addresses.
Tests:
- When WireGuard mobile app is configured, it fails to resolve addresses. When
Bind app is installed and enabled, it is able to resolve addresses and browse
internet as expected.
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
Tests:
- Install WireGuard app without patches. Create a few clients. Both the server
and the clients don't have IPv6 addresses assigned to them. Apply the patches.
Restart FreedomBox. WireGuard app setup is run. Server gets an IPv6 address and
so do the clients.
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
- Move server information (such as public key) to 'Add Client' page. It is only
needed there. 'Add Client Automatically' shows this information anyway and also
fills the configuration provided by QR code and file.
- Rename 'Allowed Client' to simply 'Client' and 'Peer' to 'Client' for
consistency and simplicity.
- Auto-generate a key pair for manual client addition also. The user may choose
to provide their own public like before.
- Provide description to what "As a Server" and "As a Client" mean.
- Provide server consistent information everywhere in a tabular format. This is
drawn from 'Add Client Automatically' page after improvements. The objective is
to make it easy for user to use WireGuard mobile app. So, use terminology from
there.
- Provide 'FreedomBox Server' IP addresses everywhere.
- Change how multiple endpoints are shown in the table.
Tests:
- WireGuard page has following changes:
- Server information is not shown.
- Description is shown in both the sections.
- 'Add Allowed Client' button changed to 'Add Client'.
- Show client page has following changes:
- Information is reorganized into two sections. All information present and
correct.
- Headers are styled differently.
- 'FreedomBox Server' row is shown.
- Table is divided into two separate sections.
- Add client automatically page has following changes:
- FreedomBox Server IPs are shown.
- Table is divided into two separate sections.
- Headers are styled differently.
- Add Client page has following changes:
- New description
- Server information table is shown just like in 'Add Client Automatically'
page. Extra information is shown for public/private keys and endpoints.
- Public key and private keys are auto-generated.
- Public key field is pre-populated.
- Submitting the form creates the client with provided public key.
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
- When the WireGuard interface on the client lacks IPv6 address, it is possible
that the IPv6 traffic leaks and goes directly to Internet instead of via
FreedomBox. Fix this by adding IPv6 address on the FreedomBox.
- If the FreedomBox fails to forward IPv6 traffic, then the client will be
incapable using IPv6. This is better than leaking IPv6 traffic.
- In the form to add WireGuard server configuration, allow providing IPv6
address along with IPv4 address. Mullvad VPN provides such configuration.
- Don't provide IPv6 address for DNS server. Querying via IPv4 is sufficient for
both A (IPv4) queries and AAAA (IPv6) queries. Providing two different IPs (one
IPv4 and one IPv6 for the same DNS server) is not better then providing just one
IP address.
- Add DNS server information in the show client page.
Tests:
- Unit and functional tests work.
- When WireGuard app is installed and server is started, the app page shows IPv4
and IPv6 addresses of the server.
- After auto-adding client, the downloaded configuration contains two IP allowed
addresses for the client. The configuration details also contain this
information. DNS address information is correct.
- Show client page shows multiple allowed IPs for the client. Multiple IPs for
the server. DNS server is also shown.
- When adding a server configuration, multiple IPs (one IPv4 and one IPv6) can
be provided.
- When adding clients, next free IP addresses for IPv4 and IPv6 are allocated as
expected.
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
- Sometimes a newly added client can't be found even after waiting 10 seconds.
In these cases the changes are mostly lost. Raise an exception instead showing
that the client has been added.
Tests:
- When client adding fails, exception is raised instead of successfully showing
the result page.
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
- This is improved reliability of adding a new client.
Tests:
- Auto adding and removing a client works. Console messages do not warn about
deprecated commit_changes() API anymore.
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
Closes: #2341.
Tests:
- Accessing page /freedombox/help/manual/fr/Users shows an info message about
missing translation. The link points to wiki.debian.org/FreedomBox/Manual.
Refreshing the page does not show the message again. The message is shown with
proper styling of info message even in dark mode.
Signed-off-by: Frederico Gomes <fredericojfgomes@gmail.com>
[sunil: Use wiki URL instead of weblate URL]
[sunil: Use info message instead of warning message]
[sunil: Use styling compatible with dark mode]
[sunil: Work well with messages middleware in tests]
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
Closes: #1293.
Tests:
- Copy /usr/share/apache2/default-site/index.html to /var/www/html/index.html.
Apply the patches. The file in /var/www/html/index.html is removed.
- Create a new custom file in /var/www/html/index.html. Increment the setup
version so apache2 setup is run. The file is not removed.
- Copy the default file again and run setup again. The file is removed.
- Increment setup version again and there are no errors due to missing file.
[sunil: Add check to ensure that only default files are not removed]
Signed-off-by: Frederico Gomes <fredericojfgomes@gmail.com>
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Tested-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
Closes: #2587.
Tests:
- When adding a users to a group as admin, the log messages don't show
authorization password in clear text. Instead the value is masked as '****'.
This works even when add_user_to_group privileged call uses keyword arguments
instead of positional arguments.
- When taking a backup for dynamicdns app, log message for the dump_settings()
does not show account passwords. Instead the value is masked as '****'.
- When a privileged method contains an annotation 'password: str' an exception
is raised during startup saying that it should be a secret. When the annotation
is 'password: secret_str' it works. When the annotation is 'password:
Annotated[str, Secret]' it works.
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
Fixes: #2588.
Otherwise, unprivileged user accounts can read/write files that they were not
permitted to by setting the authorized_keys file to be a symlink.
Tests:
- Editing page for freshly created user (as root or as user) shows empty value
for authorized_keys.
- Setting SSH key for freshly created user works (as root or as user). File is
created. Permissions are 0o644 and ownership is the user:'users'. .ssh
directory is created with user:'users' ownership. Login works after setting
the keys.
- After setting authorized keys they are shown properly in the user edit page.
- Editing again works.
- Clearing the values work.
- Linking authorized_key to another file owned (with proper permissions,
ownership) by the user works. Values are shown properly in the edit page.
Setting values works. SSH Login works.
- Linking the authorized_keys file to /etc/shadow leads to returning empty
string.
- Linking the authorized_keys file to /etc/shadow, writing keys fails. Error
message is shown 'Unable to set SSH keys.'. Exception is shown in logs.
- Linking .ssh directory to /etc, writing keys fails. Error message is shown
'Unable to set SSH keys.'. Exception is shown in logs.
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
- When app is installed for the first time, the drop-in configuration file
/etc/apache2/includes/home-assistant-freedombox.conf is not created properly.
This is because app.enable() is not being called and not all components are
enabled (including the drop-in configuration component). Fix this by calling
app.enable() in setup().
- Ensure that apache2 is restarted after the homeassistant app is update to
version 2 from version 1.
Tests:
- On a fresh VM, without the patch, installing HA does not result in working HA
UI. With patch, on a fresh VM. It works.
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
- Without new HTTP configuration mechanism, proper configuration of HA fails.
This is because we don't setup the configuration before starting Home Assistant.
Home Assistant only migrates the old configuration to new configuration format
only on the first run. It also leaves a "repair" message to the user asking them
to remove the 'http' section from the configuration file.
- Write to the internal storage format of HA after verifying the version of the
format. Writing through API is hindered by the lack of an API token (which
apparently can't be obtained pragmatically).
Tests:
- Install without patches. configuration.yml contains http section. Home
Assistant not work as HTTP configuration is not set. Apply patches and restart
the service. The setup is run again. 'http' section in configuration.yml is
removed. /var/lib/home-assistant-freedombox/config/.storage/http contains the
required configuration keys with proper values. Home Assistant works (after
domain selection).
- Install freshly with patches. configuration.yml does not contain 'http'
section. /var/lib/home-assistant-freedombox/config/ contains the necessary
configuration changes. HA works after domain selection.
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
Tests:
- Enable scheduled backups for root and remote repo. Modify
schedule.py so that backups and cleanup will run every 2
minutes. Log shows compact command is run for both
/var/lib/freedombox/borgbackup and mount location for remote
repo. No errors shown in log.
Closes: #2380
Signed-off-by: James Valleroy <jvalleroy@mailbox.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
Tests:
- On unstable container, the test fails before the patch and passes after.
- On stable, testing, and unstable containers, unit tests pass.
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
- When waiting after a auto-client-add operation, sometimes, it is not detected
that server connection exists. Then a new server setup is triggered and this
causes a duplicate wireguard server connection created. Fix this by making wait
operations strictly read-only.
- Also add more safety checks during waiting based one of the seen failures.
Tests:
- Functional tests work.
- Auto add client works much more reliably.
[jvalleroy: Update docstring]
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
- 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>