From da4842eb7b9e7c78d14fdd2731d59855a4ec2a81 Mon Sep 17 00:00:00 2001 From: Zankaria Date: Tue, 30 Apr 2024 11:31:06 +0200 Subject: [PATCH] auth.php: disallow unencrypted logins by default --- composer.json | 1 + inc/config.php | 5 +++++ inc/functions/net.php | 10 ++++++++++ inc/mod/auth.php | 7 +++++-- inc/mod/pages.php | 9 +++++++-- 5 files changed, 28 insertions(+), 4 deletions(-) create mode 100644 inc/functions/net.php diff --git a/composer.json b/composer.json index b06ff6a1..e5b73d9b 100644 --- a/composer.json +++ b/composer.json @@ -33,6 +33,7 @@ "inc/lock.php", "inc/queue.php", "inc/functions.php", + "inc/functions/net.php", "inc/driver/http-driver.php", "inc/driver/log-driver.php", "inc/service/captcha-queries.php" diff --git a/inc/config.php b/inc/config.php index 03e6044e..2b271ee2 100644 --- a/inc/config.php +++ b/inc/config.php @@ -194,6 +194,10 @@ // Whether or not you can access the mod cookie in JavaScript. Most users should not need to change this. $config['cookies']['httponly'] = true; + // Do not allow logins via unencrypted HTTP. Should only be changed in testing environments or if you connect to a + // load-balancer without encryption. + $config['cookies']['secure_login_only'] = true; + // Used to salt secure tripcodes ("##trip") and poster IDs (if enabled). $config['secure_trip_salt'] = ')(*&^%$#@!98765432190zyxwvutsrqponmlkjihgfedcba'; @@ -1252,6 +1256,7 @@ // Moderator errors $config['error']['toomanyunban'] = _('You are only allowed to unban %s users at a time. You tried to unban %u users.'); $config['error']['invalid'] = _('Invalid username and/or password.'); + $config['error']['insecure'] = _('Login on insecure connections is disabled.'); $config['error']['notamod'] = _('You are not a mod…'); $config['error']['invalidafter'] = _('Invalid username and/or password. Your user may have been deleted or changed.'); $config['error']['malformed'] = _('Invalid/malformed cookies.'); diff --git a/inc/functions/net.php b/inc/functions/net.php new file mode 100644 index 00000000..ab08c3cb --- /dev/null +++ b/inc/functions/net.php @@ -0,0 +1,10 @@ +