mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-10-19 05:58:34 +02:00
Merge pull request #3305 from modoboa/fix/secret-generator
Simplify and fix secret key generation
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user