From 5c28a02d30bd921a953cdeed92fcf73669b9f338 Mon Sep 17 00:00:00 2001 From: Spitap Date: Wed, 21 Aug 2024 15:57:49 +0200 Subject: [PATCH] Simplify and fix secret key generation --- modoboa/core/commands/deploy.py | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/modoboa/core/commands/deploy.py b/modoboa/core/commands/deploy.py index 16954c381..cb6311e54 100644 --- a/modoboa/core/commands/deploy.py +++ b/modoboa/core/commands/deploy.py @@ -95,12 +95,6 @@ class DeployCommand(Command): default="admin", help="Username of the initial super administrator", ) - self._parser.add_argument( - "--secret-key-length", - default=60, - type=int, - help="Specify the length of the secret key", - ) def _exec_django_command(self, name, cwd, *args): """Run a django command for the freshly created project @@ -174,14 +168,6 @@ class DeployCommand(Command): official_exts = ModoAPIClient(url).list_extensions() return [extension["name"] for extension in official_exts] - def _generate_secret_key(self, secret_key_length): - """Generate a secret key since the one generated by django - is marked as insecure. - """ - c = string.ascii_letters + string.digits + string.punctuation - secret_key = "".join(secrets.choice(c) for i in range(secret_key_length)) - return secret_key - def find_extra_settings(self, extensions): """Install one or more extensions. @@ -255,7 +241,7 @@ class DeployCommand(Command): "%s/settings.py.tpl" % self._templates_dir, { "db_connections": connections, - "secret_key": self._generate_secret_key(parsed_args.secret_key_length), + "secret_key": management.utils.get_random_secret_key(), "name": parsed_args.name, "allowed_host": allowed_host, "lang": parsed_args.lang,