From 801ca5a788a087020e3de2327b0435cd2e853ce4 Mon Sep 17 00:00:00 2001 From: Guillaume Rossolini Date: Mon, 23 Dec 2024 18:00:00 +0100 Subject: [PATCH 01/30] Update README.md Replaced dead link for SSL certificates --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 59467b59..584f9a25 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![Release 3.2.4](https://img.shields.io/badge/release-v3.2.4-green)](https://github.com/raspap/raspap-webgui/releases) [![Awesome](https://awesome.re/badge.svg)](https://github.com/thibmaek/awesome-raspberry-pi) [![Join Insiders](https://img.shields.io/static/v1?label=Insiders&message=%E2%9D%A4&logo=GitHub&color=ff69b4)](https://github.com/sponsors/RaspAP) [![Build Status](https://app.travis-ci.com/RaspAP/raspap-webgui.svg?branch=master)](https://app.travis-ci.com/RaspAP/raspap-webgui) [![Crowdin](https://badges.crowdin.net/raspap/localized.svg)](https://crowdin.com/project/raspap) [![Twitter URL](https://img.shields.io/twitter/url?label=%40RaspAP&logoColor=%23d8224c&url=https%3A%2F%2Ftwitter.com%2Frasp_ap)](https://twitter.com/rasp_ap) [![Reddit](https://img.shields.io/badge/%2Fr%2FRaspAP-e05d44?style=flat&logo=Reddit&logoColor=white&labelColor=e05d44&color=b14835)](https://reddit.com/r/RaspAP) [![Discord](https://img.shields.io/discord/642436993451819018?color=7289DA&label=Discord&logo=discord&style=flat)](https://discord.gg/KVAsaAR) -RaspAP is feature-rich wireless router software that _just works_ on many popular [Debian-based devices](#supported-operating-systems), including the Raspberry Pi. Our popular [Quick installer](#quick-installer) and [Docker container](#docker-support) create a known-good default configuration for all current Raspberry Pis with onboard wireless. A fully responsive, mobile-ready interface gives you control over the relevant services and networking options. Advanced DHCP settings, WireGuard and OpenVPN support, [SSL certificates](https://docs.raspap.com/ssl-quick/), security audits, [captive portal integration](https://docs.raspap.com/captive/), themes and [multilingual options](https://docs.raspap.com/translations/) are included. +RaspAP is feature-rich wireless router software that _just works_ on many popular [Debian-based devices](#supported-operating-systems), including the Raspberry Pi. Our popular [Quick installer](#quick-installer) and [Docker container](#docker-support) create a known-good default configuration for all current Raspberry Pis with onboard wireless. A fully responsive, mobile-ready interface gives you control over the relevant services and networking options. Advanced DHCP settings, WireGuard and OpenVPN support, [SSL certificates](https://docs.raspap.com/ssl/), security audits, [captive portal integration](https://docs.raspap.com/captive/), themes and [multilingual options](https://docs.raspap.com/translations/) are included. RaspAP has been featured on sites such as [Instructables](http://www.instructables.com/id/Raspberry-Pi-As-Completely-Wireless-Router/), [Adafruit](https://blog.adafruit.com/2016/06/24/raspap-wifi-configuration-portal-piday-raspberrypi-raspberry_pi/), [Raspberry Pi Weekly](https://www.raspberrypi.org/weekly/commander/) and [Awesome Raspberry Pi](https://project-awesome.org/thibmaek/awesome-raspberry-pi) and implemented in countless projects. From 5902a8d6a014ca94884c302ccf09eb40b667fdcc Mon Sep 17 00:00:00 2001 From: billz Date: Wed, 1 Jan 2025 00:37:25 -0800 Subject: [PATCH 02/30] Update template + wg-keygen js handler --- app/js/custom.js | 12 ++++++------ templates/wg/peers.php | 6 ++---- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/app/js/custom.js b/app/js/custom.js index 53ea7ae3..c33a5d5a 100644 --- a/app/js/custom.js +++ b/app/js/custom.js @@ -623,18 +623,18 @@ function clearBlocklistStatus() { $('#cbxblocklist-status').removeClass('check-updated').addClass('check-hidden'); } -// Handler for the wireguard generate key button +// Handler for the WireGuard generate key button $('.wg-keygen').click(function(){ - var entity_pub = $(this).parent('div').prev('input[type="text"]'); - var entity_priv = $(this).parent('div').next('input[type="hidden"]'); + var parentGroup = $(this).closest('.input-group'); + var entity_pub = parentGroup.find('input[type="text"]'); var updated = entity_pub.attr('name')+"-pubkey-status"; - var csrfToken = $('meta[name=csrf_token]').attr('content'); + var csrfToken = $('meta[name="csrf_token"]').attr('content'); $.post('ajax/networking/get_wgkey.php',{'entity':entity_pub.attr('name'), 'csrf_token': csrfToken},function(data){ var jsonData = JSON.parse(data); entity_pub.val(jsonData.pubkey); $('#' + updated).removeClass('check-hidden').addClass('check-updated').delay(500).animate({ opacity: 1 }, 700); - }) -}) + }); +}); // Handler for wireguard client.conf download $('.wg-client-dl').click(function(){ diff --git a/templates/wg/peers.php b/templates/wg/peers.php index fad228c4..a625b4c9 100644 --- a/templates/wg/peers.php +++ b/templates/wg/peers.php @@ -21,10 +21,8 @@
-
- - -
+
+
From 531970d9c6c6d4ed0c7e286ba905d1b17c191816 Mon Sep 17 00:00:00 2001 From: billz Date: Wed, 1 Jan 2025 00:41:56 -0800 Subject: [PATCH 03/30] Extend wg peer endpoint validation w/ subdomain + hostname --- includes/wireguard.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/includes/wireguard.php b/includes/wireguard.php index ed47a6e1..2cca31db 100755 --- a/includes/wireguard.php +++ b/includes/wireguard.php @@ -207,7 +207,10 @@ function SaveWireGuardConfig($status) } if (isset($_POST['wg_pendpoint']) && strlen(trim($_POST['wg_pendpoint']) >0 )) { $wg_pendpoint_seg = substr($_POST['wg_pendpoint'],0,strpos($_POST['wg_pendpoint'],':')); - if (!filter_var($wg_pendpoint_seg,FILTER_VALIDATE_IP)) { + $host_port = explode(':', $wg_pendpoint_seg); + $hostname = $host_port[0]; + if (!filter_var($hostname, FILTER_VALIDATE_IP) && + !filter_var($hostname, FILTER_VALIDATE_DOMAIN, FILTER_FLAG_HOSTNAME)) { $status->addMessage('Invalid value for endpoint address', 'danger'); $good_input = false; } From bfd5859ce1b87cb0f9c3e85f1ee5bfce6aaa6b4a Mon Sep 17 00:00:00 2001 From: billz Date: Fri, 3 Jan 2025 00:38:45 -0800 Subject: [PATCH 04/30] Revise bootstrap 5.3 adblock update btn --- templates/adblock/general.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/templates/adblock/general.php b/templates/adblock/general.php index c39a8b41..ff3d16f5 100644 --- a/templates/adblock/general.php +++ b/templates/adblock/general.php @@ -30,10 +30,8 @@ -
- - -
+ + From 0c31b5ba714d4c7608f8c4317b1b49427e5d492e Mon Sep 17 00:00:00 2001 From: billz Date: Sun, 19 Jan 2025 00:23:06 -0800 Subject: [PATCH 05/30] Set dhcp-ignore=tag:!known from option switch --- includes/dhcp.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/includes/dhcp.php b/includes/dhcp.php index 47b8edfa..fd6a47ac 100755 --- a/includes/dhcp.php +++ b/includes/dhcp.php @@ -268,6 +268,9 @@ function updateDnsmasqConfig($iface,$status) } $config .= PHP_EOL; } + if ($_POST['dhcp-ignore'] == "1") { + $config .= 'dhcp-ignore=tag:!known'.PHP_EOL; + } file_put_contents("/tmp/dnsmasqdata", $config); $msg = file_exists(RASPI_DNSMASQ_PREFIX.$iface.'.conf') ? 'updated' : 'added'; system('sudo cp /tmp/dnsmasqdata '.RASPI_DNSMASQ_PREFIX.$iface.'.conf', $result); From 6f1c34f28d0168d8ea6647ef3e459b11078e4dc7 Mon Sep 17 00:00:00 2001 From: billz Date: Mon, 20 Jan 2025 00:51:00 -0800 Subject: [PATCH 06/30] Initial commit --- ajax/session/do_check_session.php | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 ajax/session/do_check_session.php diff --git a/ajax/session/do_check_session.php b/ajax/session/do_check_session.php new file mode 100644 index 00000000..401ea30c --- /dev/null +++ b/ajax/session/do_check_session.php @@ -0,0 +1,28 @@ += RASPI_SESSION_TIMEOUT ? 'session_expired' : 'active'; + +// send response +header('Content-Type: application/json'); +header('Cache-Control: no-store, no-cache, must-revalidate, max-age=0'); +header('Expires: Thu, 01 Jan 1970 00:00:00 GMT'); +header('Pragma: no-cache'); + +$response = [ + 'status' => $status, + 'last_activity' => $lastActivity, + 'session_lifetime' => $sessionLifetime, + 'timeout_duration' => RASPI_SESSION_TIMEOUT +]; + +echo json_encode($response); +exit(); + From 3cf22a9cbbaea8bafd9b1784cc9ecaac4fd8569c Mon Sep 17 00:00:00 2001 From: billz Date: Mon, 20 Jan 2025 00:52:28 -0800 Subject: [PATCH 07/30] Define RASPI_SESSION_TIMEOUT --- config/config.php | 1 + includes/defaults.php | 1 + 2 files changed, 2 insertions(+) diff --git a/config/config.php b/config/config.php index 2950632d..feaeecea 100755 --- a/config/config.php +++ b/config/config.php @@ -11,6 +11,7 @@ define('RASPI_CACHE_PATH', sys_get_temp_dir() . '/raspap'); define('RASPI_ERROR_LOG', sys_get_temp_dir() . '/raspap_error.log'); define('RASPI_DEBUG_LOG', 'raspap_debug.log'); define('RASPI_LOG_SIZE_LIMIT', 64); +define('RASPI_SESSION_TIMEOUT', 1440); // Constants for configuration file paths. // These are typical for default RPi installs. Modify if needed. diff --git a/includes/defaults.php b/includes/defaults.php index 3b918b58..e7c42cbd 100755 --- a/includes/defaults.php +++ b/includes/defaults.php @@ -16,6 +16,7 @@ $defaults = [ 'RASPI_ERROR_LOG' => sys_get_temp_dir() . '/raspap_error.log', 'RASPI_DEBUG_LOG' => 'raspap_debug.log', 'RASPI_LOG_SIZE_LIMIT' => 64, + 'RASPI_SESSION_TIMEOUT' => 1440, // Constants for configuration file paths. // These are typical for default RPi installs. Modify if needed. From 866d8eb5b02b132f9332d8dea3e655d6b480f0c2 Mon Sep 17 00:00:00 2001 From: billz Date: Mon, 20 Jan 2025 00:53:26 -0800 Subject: [PATCH 08/30] Update w/ sessionTimeoutModal, lastActivity --- includes/footer.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/includes/footer.php b/includes/footer.php index 38965fc6..c35a2fc2 100644 --- a/includes/footer.php +++ b/includes/footer.php @@ -1,3 +1,5 @@ + +
v | @@ -8,3 +10,19 @@
+ + From c51b520b8dec840c059f2bc20f1b682fc0f0a12a Mon Sep 17 00:00:00 2001 From: billz Date: Mon, 20 Jan 2025 00:55:21 -0800 Subject: [PATCH 09/30] Decouple session from csrf handler, set initial lastActivity --- includes/csrf.php | 1 - includes/session.php | 5 +++++ index.php | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/includes/csrf.php b/includes/csrf.php index bca935df..4e098e5b 100755 --- a/includes/csrf.php +++ b/includes/csrf.php @@ -1,7 +1,6 @@ Date: Mon, 20 Jan 2025 00:58:18 -0800 Subject: [PATCH 10/30] Add checkSession(), showSessionExpiredModal() --- app/js/custom.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/app/js/custom.js b/app/js/custom.js index c33a5d5a..d63daa05 100644 --- a/app/js/custom.js +++ b/app/js/custom.js @@ -671,6 +671,28 @@ window.addEventListener('load', function() { }); }, false); +let sessionCheckInterval = setInterval(checkSession, 5000); + +function checkSession() { + $.get('ajax/session/do_check_session.php', function (data) { + if (data.status === 'session_expired') { + clearInterval(sessionCheckInterval); + showSessionExpiredModal(); + } + }).fail(function (jqXHR, status, err) { + console.error("Error checking session status:", status, err); + }); +} + +function showSessionExpiredModal() { + $('#sessionTimeoutModal').modal('show'); +} + +$(document).on("click", "#js-session-expired-login", function(e) { + console.log('clicked!'); + window.location.href = '/login'; +}); + // DHCP or Static IP option group $('#chkstatic').on('change', function() { if (this.checked) { From 3f883a70de2757a56d23b3cf40206af0b5d938e7 Mon Sep 17 00:00:00 2001 From: billz Date: Tue, 21 Jan 2025 00:29:14 -0800 Subject: [PATCH 11/30] Initial commit --- includes/login.php | 38 ++++++++++++++++++++++++++++++++++++++ templates/login.php | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+) create mode 100644 includes/login.php create mode 100644 templates/login.php diff --git a/includes/login.php b/includes/login.php new file mode 100644 index 00000000..89374894 --- /dev/null +++ b/includes/login.php @@ -0,0 +1,38 @@ +login($username, $password)) { + $config = $auth->getAuthConfig(); + header('Location: ' . $redirectUrl); + die(); + } else { + $status = "Login failed"; + } + } + } + + echo renderTemplate( + "login", compact( + "status", + "redirectUrl" + ) + ); +} + diff --git a/templates/login.php b/templates/login.php new file mode 100644 index 00000000..41d1f3f1 --- /dev/null +++ b/templates/login.php @@ -0,0 +1,42 @@ + + + From 792ce0c956a4c21fd1f88f35f3f66933f655dfc4 Mon Sep 17 00:00:00 2001 From: billz Date: Tue, 21 Jan 2025 00:29:59 -0800 Subject: [PATCH 12/30] Include login.php, buffer page output --- index.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/index.php b/index.php index badd2762..3e060dc0 100755 --- a/index.php +++ b/index.php @@ -36,6 +36,7 @@ require_once 'includes/functions.php'; // Default page actions require_once 'includes/dashboard.php'; +require_once 'includes/login.php'; require_once 'includes/authenticate.php'; require_once 'includes/admin.php'; require_once 'includes/dhcp.php'; @@ -97,6 +98,7 @@ initializeApp(); +
@@ -124,6 +126,7 @@ initializeApp();
+ From 6dbdf89760718a6205a13568405b47904ca3a666 Mon Sep 17 00:00:00 2001 From: billz Date: Tue, 21 Jan 2025 00:30:40 -0800 Subject: [PATCH 13/30] Add DisplayLogin() page handler --- includes/page_actions.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/includes/page_actions.php b/includes/page_actions.php index 2e406bf8..c9649792 100755 --- a/includes/page_actions.php +++ b/includes/page_actions.php @@ -70,6 +70,9 @@ function handleCorePageAction(string $page, array &$extraFooterScripts): void case "/about": DisplayAbout(); break; + case "/login": + DisplayLogin(); + break; default: DisplayDashboard($extraFooterScripts); } From 6cb0be96b461a78ac24c64bbdadace8fff69f6c9 Mon Sep 17 00:00:00 2001 From: billz Date: Tue, 21 Jan 2025 00:31:49 -0800 Subject: [PATCH 14/30] Set data-bs-backdrop + data-bs-keyboard attributes --- includes/footer.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/footer.php b/includes/footer.php index c35a2fc2..b12c0f1c 100644 --- a/includes/footer.php +++ b/includes/footer.php @@ -1,6 +1,6 @@ -
+
v | Created by the RaspAP Team @@ -10,7 +10,7 @@
-