Default login crediantials in config

This commit is contained in:
Deividas Raila 2024-05-07 18:11:07 +03:00
parent 65d58cfd92
commit 3b69fcf770
2 changed files with 9 additions and 3 deletions

View file

@ -27,6 +27,10 @@ $logsdirectory = "../etc";
# Location of user-database. Make sure its writeable and not served by the webserver! # Location of user-database. Make sure its writeable and not served by the webserver!
$authdb = "../etc/pdns.users.sqlite3"; $authdb = "../etc/pdns.users.sqlite3";
# Admin login and password at first start-up
$default_admin_username = "admin";
$default_admin_password = "admin";
# Set a random generated secret to enable auto-login and long living csrf tokens # Set a random generated secret to enable auto-login and long living csrf tokens
// $secret = '...'; // $secret = '...';

View file

@ -66,7 +66,9 @@ try {
$createsql = file_get_contents('includes/scheme.sql'); $createsql = file_get_contents('includes/scheme.sql');
$db->exec($createsql); $db->exec($createsql);
$salt = bin2hex(openssl_random_pseudo_bytes(16)); $salt = bin2hex(openssl_random_pseudo_bytes(16));
$db->exec("INSERT INTO users (emailaddress, password, isadmin) VALUES ('admin', '".crypt("admin", '$6$'.$salt)."', 1)"); $default_admin_username = $default_admin_username ?? "admin";
$default_admin_password = $default_admin_password ?? "admin";
$db->exec("INSERT INTO users (emailaddress, password, isadmin) VALUES ('".$default_admin_username."', '".crypt($default_admin_password, '$6$'.$salt)."', 1)");
} }
} catch (Exception $e) { } catch (Exception $e) {
print("We have issues getting the authdb working: $e"); print("We have issues getting the authdb working: $e");