diff --git a/app/classes/controllers/users_controller.py b/app/classes/controllers/users_controller.py index 5c6dd3d2..5425fbf8 100644 --- a/app/classes/controllers/users_controller.py +++ b/app/classes/controllers/users_controller.py @@ -52,7 +52,7 @@ class UsersController: }, "password": { "type": "string", - "minLength": 8, + "minLength": self.helper.minimum_password_length, "examples": ["crafty"], "title": "Password", }, diff --git a/app/classes/shared/command.py b/app/classes/shared/command.py index 155fe083..95a83047 100644 --- a/app/classes/shared/command.py +++ b/app/classes/shared/command.py @@ -77,11 +77,11 @@ class MainPrompt(cmd.Cmd): # get new password from user new_pass = getpass.getpass(prompt=f"NEW password for: {username} > ") # check to make sure it fits our requirements. - if len(new_pass) > 512: - Console.warning("Passwords must be greater than 6char long and under 512") - return False - if len(new_pass) < 6: - Console.warning("Passwords must be greater than 6char long and under 512") + if len(new_pass) < self.helper.minimum_password_length: + Console.warning( + "Passwords must be greater than" + f" {self.helper.minimum_password_length} char long" + ) return False # grab repeated password input new_pass_conf = getpass.getpass(prompt="Re-enter your password: > ") diff --git a/app/classes/shared/helpers.py b/app/classes/shared/helpers.py index 9c63a323..9dff8356 100644 --- a/app/classes/shared/helpers.py +++ b/app/classes/shared/helpers.py @@ -81,6 +81,7 @@ class Helpers: self.update_available = False self.ignored_names = ["crafty_managed.txt", "db_stats"] self.crafty_starting = False + self.minimum_password_length = 8 @staticmethod def auto_installer_fix(ex): diff --git a/app/classes/shared/main_models.py b/app/classes/shared/main_models.py index c166b7fb..0cced56f 100644 --- a/app/classes/shared/main_models.py +++ b/app/classes/shared/main_models.py @@ -18,13 +18,20 @@ class DatabaseBuilder: logger.info("Fresh Install Detected - Creating Default Settings") Console.info("Fresh Install Detected - Creating Default Settings") default_data = self.helper.find_default_password() - if password not in default_data: + if "password" not in default_data: Console.help( "No default password found. Using password created " "by Crafty. Find it in app/config/default-creds.txt" ) username = default_data.get("username", "admin") - password = default_data.get("password", password) + if self.helper.minimum_password_length > default_data.get("password", password): + Console.critical( + "Default password too short" + " using Crafty's created default." + " Find it in app/config/default-creds.txt" + ) + else: + password = default_data.get("password", password) self.users_helper.add_user( username=username,