From aa99d10f1a41b1d738c8d4e01fec9749b158e458 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 | 3 ++- inc/config.php | 5 +++++ inc/functions/net.php | 10 ++++++++++ inc/mod/auth.php | 10 ++++++++-- inc/mod/pages.php | 9 +++++++-- 5 files changed, 32 insertions(+), 5 deletions(-) create mode 100644 inc/functions/net.php diff --git a/composer.json b/composer.json index 5f574aa6..e9ceac19 100644 --- a/composer.json +++ b/composer.json @@ -22,7 +22,8 @@ "inc/queue.php", "inc/polyfill.php", "inc/error.php", - "inc/functions.php" + "inc/functions.php", + "inc/functions/net.php" ] }, "license": "Tinyboard + vichan", diff --git a/inc/config.php b/inc/config.php index a37a2d51..d8ae7584 100644 --- a/inc/config.php +++ b/inc/config.php @@ -180,6 +180,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'; @@ -1216,6 +1220,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 @@ +