Skip to content

Commit

Permalink
fix: disallow usage of default password (#3284)
Browse files Browse the repository at this point in the history
  • Loading branch information
dvikan authored Mar 6, 2023
1 parent f0e5ef0 commit a01c1f6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
4 changes: 2 additions & 2 deletions config.default.ini.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@

username = "admin"

; This default password is public knowledge. Replace it.
password = "7afbf648a369b261"
; The password cannot be the empty string if authentication is enabled.
password = ""

; This will be used only for actions that require privileged access
access_token = ""
Expand Down
7 changes: 7 additions & 0 deletions lib/AuthenticationMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@

final class AuthenticationMiddleware
{
public function __construct()
{
if (Configuration::getConfig('authentication', 'password') === '') {
throw new \Exception('The authentication password cannot be the empty string');
}
}

public function __invoke(): void
{
$user = $_SERVER['PHP_AUTH_USER'] ?? null;
Expand Down
2 changes: 1 addition & 1 deletion lib/RssBridge.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ private function run($request): void
// Consider: ini_set('error_reporting', E_ALL & ~E_DEPRECATED);
date_default_timezone_set(Configuration::getConfig('system', 'timezone'));

$authenticationMiddleware = new AuthenticationMiddleware();
if (Configuration::getConfig('authentication', 'enable')) {
$authenticationMiddleware = new AuthenticationMiddleware();
$authenticationMiddleware();
}

Expand Down

0 comments on commit a01c1f6

Please sign in to comment.