Skip to content

Commit

Permalink
early fail if old password variable (wg-easy#1350)
Browse files Browse the repository at this point in the history
  • Loading branch information
kaaax0815 authored Sep 4, 2024
1 parent 3f6b6f3 commit 4ba7dc2
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ services:
- NET_ADMIN
- SYS_MODULE
environment:
# - PASSWORD=p
# - PASSWORD_HASH=p
- WG_HOST=192.168.1.233
2 changes: 2 additions & 0 deletions src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ const { release: { version } } = require('./package.json');
module.exports.RELEASE = version;
module.exports.PORT = process.env.PORT || '51821';
module.exports.WEBUI_HOST = process.env.WEBUI_HOST || '0.0.0.0';
/** This is only kept for migration purpose. DO NOT USE! */
module.exports.PASSWORD = process.env.PASSWORD;
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/';
Expand Down
5 changes: 5 additions & 0 deletions src/lib/Server.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const {
PORT,
WEBUI_HOST,
RELEASE,
PASSWORD,
PASSWORD_HASH,
MAX_AGE,
LANG,
Expand Down Expand Up @@ -428,6 +429,10 @@ module.exports = class Server {
}),
);

if (PASSWORD) {
throw new Error('DO NOT USE PASSWORD ENVIRONMENT VARIABLE. USE PASSWORD_HASH INSTEAD.\nSee https://github.com/wg-easy/wg-easy/blob/master/How_to_generate_an_bcrypt_hash.md');
}

createServer(toNodeListener(app)).listen(PORT, WEBUI_HOST);
debug(`Listening on http://${WEBUI_HOST}:${PORT}`);

Expand Down

0 comments on commit 4ba7dc2

Please sign in to comment.