From a268422e9d5409e2d98af1769b495836a1ea5983 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A8=8B=E8=B6=8A?= <44216455+cyicz123@users.noreply.github.com> Date: Mon, 12 Aug 2024 11:12:21 +0800 Subject: [PATCH 01/39] fix(Doc): fix escaping issue for PASSWORD_HASH in docker-compose.yml For users using docker-compose.yml, please note that you should not wrap the generated hash password in single quotes. Instead, replace each `$` symbol with two `$$` symbols. For example, for the password 'foobar123', use the following command to generate the hash: `docker run ghcr.io/wg-easy/wg-easy wgpw foobar123` The resulting hash should be used in docker-compose.yml like this: ``` yaml - PASSWORD_HASH=$$2y$$10$$hBCoykrB95WSzuV4fafBzOHWKu9sbyVa34GJr8VV5R/pIelfEMYyG ``` Signed-off-by: cyicz123 --- How_to_generate_an_bcrypt_hash.md | 10 +++++++++- docker-compose.yml | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/How_to_generate_an_bcrypt_hash.md b/How_to_generate_an_bcrypt_hash.md index 1a6a63c..e77e371 100644 --- a/How_to_generate_an_bcrypt_hash.md +++ b/How_to_generate_an_bcrypt_hash.md @@ -16,7 +16,7 @@ docker run ghcr.io/wg-easy/wg-easy wgpw YOUR_PASSWORD PASSWORD_HASH='$2b$12$coPqCsPtcFO.Ab99xylBNOW4.Iu7OOA2/ZIboHN6/oyxca3MWo7fW' // literally YOUR_PASSWORD ``` -*Important* : make sure to enclose your password in **single quotes** when you run `docker run` command : +**Important** : make sure to enclose your password in **single quotes** when you run `docker run` command : ```bash $ echo $2b$12$coPqCsPtcF <-- not correct @@ -26,3 +26,11 @@ b2 $ echo '$2b$12$coPqCsPtcF' <-- correct $2b$12$coPqCsPtcF ``` + +**Important** : Please note: don't wrap the generated hash password in single quotes when you use `docker-compose.yml`. Instead, replace each `$` symbol with two `$$` symbols. For example: + +``` yaml +- PASSWORD_HASH=$$2y$$10$$hBCoykrB95WSzuV4fafBzOHWKu9sbyVa34GJr8VV5R/pIelfEMYyG +``` + +This hash is for the password 'foobar123', obtained using the command `docker run ghcr.io/wg-easy/wg-easy wgpw foobar123` and then inserted an additional `$` before each existing `$` symbal. diff --git a/docker-compose.yml b/docker-compose.yml index f4c93c4..dd450ed 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -12,7 +12,7 @@ services: - WG_HOST=raspberrypi.local # Optional: - # - PASSWORD_HASH='$2y$10$hBCoykrB95WSzuV4fafBzOHWKu9sbyVa34GJr8VV5R/pIelfEMYyG' (hash of 'foobar123'; see "How_to_generate_an_bcrypt_hash.md" for generate the hash) + # - PASSWORD_HASH=$$2y$$10$$hBCoykrB95WSzuV4fafBzOHWKu9sbyVa34GJr8VV5R/pIelfEMYyG (needs double $$, hash of 'foobar123'; see "How_to_generate_an_bcrypt_hash.md" for generate the hash) # - PORT=51821 # - WG_PORT=51820 # - WG_CONFIG_PORT=92820 From 0bf266d5cb77d754b450d91545c792a6314a87d5 Mon Sep 17 00:00:00 2001 From: NPM Update Bot Date: Mon, 12 Aug 2024 08:56:59 +0000 Subject: [PATCH 02/39] npm: package updates --- src/package-lock.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/package-lock.json b/src/package-lock.json index a07c2bb..52d1e5f 100644 --- a/src/package-lock.json +++ b/src/package-lock.json @@ -2658,9 +2658,9 @@ } }, "node_modules/ignore": { - "version": "5.3.1", - "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.1.tgz", - "integrity": "sha512-5Fytz/IraMjqpwfd34ke28PTVMjZjJG2MPn5t7OE4eUCUNf8BAa7b5WUS9/Qvr6mwOQS7Mk6vdsMno5he+T8Xw==", + "version": "5.3.2", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.2.tgz", + "integrity": "sha512-hsBTNUqQTDwkWtcdYI2i06Y/nUBEsNEDJKjWdigLvegy8kDuJAS8uRlpkkcQpyEXL0Z/pjDy5HBmMjRCJ2gq+g==", "dev": true, "license": "MIT", "engines": { From 0386a0da6b350efc7791166e9553256e28c50780 Mon Sep 17 00:00:00 2001 From: Bernd Storath <999999bst@gmail.com> Date: Mon, 12 Aug 2024 16:30:58 +0200 Subject: [PATCH 03/39] add better issue template Co-authored-by: Bernd Storath --- .github/ISSUE_TEMPLATE/01-bug-report.yml | 38 +++++++++++++++ .github/ISSUE_TEMPLATE/02-feature-request.yml | 48 +++++++++++++++++++ .github/ISSUE_TEMPLATE/bug_report.md | 38 --------------- .github/ISSUE_TEMPLATE/config.yml | 5 ++ 4 files changed, 91 insertions(+), 38 deletions(-) create mode 100644 .github/ISSUE_TEMPLATE/01-bug-report.yml create mode 100644 .github/ISSUE_TEMPLATE/02-feature-request.yml delete mode 100644 .github/ISSUE_TEMPLATE/bug_report.md create mode 100644 .github/ISSUE_TEMPLATE/config.yml diff --git a/.github/ISSUE_TEMPLATE/01-bug-report.yml b/.github/ISSUE_TEMPLATE/01-bug-report.yml new file mode 100644 index 0000000..2a92e7b --- /dev/null +++ b/.github/ISSUE_TEMPLATE/01-bug-report.yml @@ -0,0 +1,38 @@ +--- +name: 🐛 Bug Report +description: Create a report to help us improve +title: "[Bug]: " +labels: + - "bug" + +body: + - type: markdown + attributes: + value: | + **Thanks :heart: for taking the time to fill out this bug report!** + We kindly ask that you search to see if an issue [already exists](https://github.com/wg-easy/wg-easy/issues?q=is%3Aissue+sort%3Acreated-desc+) for the bug you encountered. + + - type: textarea + id: what-happened + attributes: + label: Describe the bug + placeholder: Tell us what you see! + value: "A bug happened!" + validations: + required: true + + - type: textarea + id: what-should-happen + attributes: + label: Expected behavior + placeholder: Tell us what you expected! + value: "Work just fine!" + validations: + required: true + + - type: textarea + id: logs + attributes: + label: Relevant log output + description: Please copy and paste any relevant log output. This will be automatically formatted into code, so no need for backticks. + render: shell diff --git a/.github/ISSUE_TEMPLATE/02-feature-request.yml b/.github/ISSUE_TEMPLATE/02-feature-request.yml new file mode 100644 index 0000000..d23b5f6 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/02-feature-request.yml @@ -0,0 +1,48 @@ +--- +name: 🛠️ Feature Request +description: Suggest an idea to help us improve +title: "[Feat]: " +labels: + - "enhancement" + +body: + - type: markdown + attributes: + value: | + **Thanks :heart: for taking the time to fill out this feature request report!** + We kindly ask that you search to see if an issue [already exists](https://github.com/wg-easy/wg-easy/issues?q=is%3Aissue+sort%3Acreated-desc+) for your feature. + + We are also happy to accept contributions from our users. For more details see [here](https://github.com/wg-easy/wg-easy/blob/master/contributing.md). + + - type: textarea + attributes: + label: Description + description: | + A clear and concise description of the feature you're interested in. + validations: + required: true + + - type: textarea + attributes: + label: Suggested Solution + description: | + Describe the solution you'd like. A clear and concise description of what you want to happen. + validations: + required: true + + - type: textarea + attributes: + label: Alternatives + description: | + Describe alternatives you've considered. + A clear and concise description of any alternative solutions or features you've considered. + validations: + required: false + + - type: textarea + attributes: + label: Additional Context + description: | + Add any other context about the problem here. + validations: + required: false diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md deleted file mode 100644 index 89daa66..0000000 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ /dev/null @@ -1,38 +0,0 @@ ---- -name: Bug report -about: Create a report to help us improve -title: '' -labels: '' -assignees: '' - ---- - -**Describe the bug** -A clear and concise description of what the bug is. - -**To Reproduce** -Steps to reproduce the behavior: -1. Go to '...' -2. Click on '....' -3. Scroll down to '....' -4. See error - -**Expected behavior** -A clear and concise description of what you expected to happen. - -**Screenshots** -If applicable, add screenshots to help explain your problem. - -**Desktop (please complete the following information):** - - OS: [e.g. macOS 12.1] - - Browser [e.g. chrome, safari] - - Version [e.g. 22] - -**Smartphone (please complete the following information):** - - Device: [e.g. iPhone6] - - OS: [e.g. iOS 8.1] - - Browser [e.g. stock browser, safari] - - Version [e.g. 22] - -**Additional context** -Add any other context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 0000000..421000e --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,5 @@ +contact_links: + - name: Get Help + url: https://github.com/wg-easy/wg-easy/discussions/new?category=q-a + about: If you can't get something to work the way you expect, open a question in the discussions. +blank_issues_enabled: false \ No newline at end of file From 4e79d0ee03211dc6148db66ee7e4dcd24c8098ac Mon Sep 17 00:00:00 2001 From: NPM Update Bot Date: Mon, 12 Aug 2024 14:56:03 +0000 Subject: [PATCH 04/39] npm: package updates --- src/package-lock.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/package-lock.json b/src/package-lock.json index 52d1e5f..c1781a1 100644 --- a/src/package-lock.json +++ b/src/package-lock.json @@ -3905,9 +3905,9 @@ } }, "node_modules/postcss-selector-parser": { - "version": "6.1.1", - "resolved": "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-6.1.1.tgz", - "integrity": "sha512-b4dlw/9V8A71rLIDsSwVmak9z2DuBUB7CA1/wSdelNEzqsjoSPeADTWNO09lpH49Diy3/JIZ2bSPB1dI3LJCHg==", + "version": "6.1.2", + "resolved": "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-6.1.2.tgz", + "integrity": "sha512-Q8qQfPiZ+THO/3ZrOrO0cJJKfpYCagtMUkXbnEfmgUjwXg6z/WBeOyS9APBBPCTSiDV+s4SwQGu8yFsiMRIudg==", "dev": true, "license": "MIT", "dependencies": { From 3e6ded18a566e2afc3304237a07be58714c1f92c Mon Sep 17 00:00:00 2001 From: Viktor Yudov Date: Tue, 13 Aug 2024 02:51:05 +0300 Subject: [PATCH 05/39] Add Remember me --- README.md | 1 + src/config.js | 1 + src/lib/Server.js | 11 ++++++++++- src/www/index.html | 18 ++++++++++++++++++ src/www/js/api.js | 11 +++++++++-- src/www/js/app.js | 8 ++++++++ src/www/js/i18n.js | 2 ++ 7 files changed, 49 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index be8a32c..f39e7e6 100644 --- a/README.md +++ b/README.md @@ -120,6 +120,7 @@ These options can be configured by setting environment variables using `-e KEY=" | `LANG` | `en` | `de` | Web UI language (Supports: en, ua, ru, tr, no, pl, fr, de, ca, es, ko, vi, nl, is, pt, chs, cht, it, th, hi). | | `UI_TRAFFIC_STATS` | `false` | `true` | Enable detailed RX / TX client stats in Web UI | | `UI_CHART_TYPE` | `0` | `1` | UI_CHART_TYPE=0 # Charts disabled, UI_CHART_TYPE=1 # Line chart, UI_CHART_TYPE=2 # Area chart, UI_CHART_TYPE=3 # Bar chart | +| `MAX_AGE` | `0` | `1440` | The maximum age of Web UI sessions in minutes. `0` means that the session will exist until the browser is closed. | > If you change `WG_PORT`, make sure to also change the exposed port. diff --git a/src/config.js b/src/config.js index 9785053..e016b38 100644 --- a/src/config.js +++ b/src/config.js @@ -6,6 +6,7 @@ module.exports.RELEASE = version; module.exports.PORT = process.env.PORT || '51821'; module.exports.WEBUI_HOST = process.env.WEBUI_HOST || '0.0.0.0'; module.exports.PASSWORD_HASH = process.env.PASSWORD_HASH; +module.exports.MAX_AGE = parseInt(process.env.MAX_AGE, 10) * 1000 * 60 || 0; module.exports.WG_PATH = process.env.WG_PATH || '/etc/wireguard/'; module.exports.WG_DEVICE = process.env.WG_DEVICE || 'eth0'; module.exports.WG_HOST = process.env.WG_HOST; diff --git a/src/lib/Server.js b/src/lib/Server.js index 7f06da5..aa5b1d4 100644 --- a/src/lib/Server.js +++ b/src/lib/Server.js @@ -29,6 +29,7 @@ const { WEBUI_HOST, RELEASE, PASSWORD_HASH, + MAX_AGE, LANG, UI_TRAFFIC_STATS, UI_CHART_TYPE, @@ -82,6 +83,11 @@ module.exports = class Server { return `"${LANG}"`; })) + .get('/api/remember-me', defineEventHandler((event) => { + setHeader(event, 'Content-Type', 'application/json'); + return MAX_AGE > 0; + })) + .get('/api/ui-traffic-stats', defineEventHandler((event) => { setHeader(event, 'Content-Type', 'application/json'); return `"${UI_TRAFFIC_STATS}"`; @@ -104,7 +110,7 @@ module.exports = class Server { }; })) .post('/api/session', defineEventHandler(async (event) => { - const { password } = await readBody(event); + const { password, remember } = await readBody(event); if (!requiresPassword) { // if no password is required, the API should never be called. @@ -122,6 +128,9 @@ module.exports = class Server { }); } + if (MAX_AGE && remember) { + event.node.req.session.cookie.maxAge = MAX_AGE; + } event.node.req.session.authenticated = true; event.node.req.session.save(); diff --git a/src/www/index.html b/src/www/index.html index 236a8f3..618acee 100644 --- a/src/www/index.html +++ b/src/www/index.html @@ -562,7 +562,25 @@ + + + + + + - + - +