Do not override secret key...
This commit is contained in:
@@ -188,6 +188,14 @@ class Modoboa(base.Installer):
|
|||||||
"handle_mailboxes": True,
|
"handle_mailboxes": True,
|
||||||
"account_auto_removal": True
|
"account_auto_removal": True
|
||||||
},
|
},
|
||||||
|
# FIXME: since we rewrite all parameters, the secret key
|
||||||
|
# previously created will disappear. As a quick fix, we
|
||||||
|
# recreate a new one here but it will mess up opened
|
||||||
|
# sessions if the installer is used to upgrade an existing
|
||||||
|
# database...
|
||||||
|
"core": {
|
||||||
|
"secret_key": utils.random_key()
|
||||||
|
},
|
||||||
"modoboa_amavis": {
|
"modoboa_amavis": {
|
||||||
"am_pdp_mode": "inet",
|
"am_pdp_mode": "inet",
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -208,3 +208,17 @@ def convert_version_to_int(version):
|
|||||||
number += num << total_bits
|
number += num << total_bits
|
||||||
total_bits += bits
|
total_bits += bits
|
||||||
return number
|
return number
|
||||||
|
|
||||||
|
|
||||||
|
def random_key(l=16):
|
||||||
|
"""Generate a random key.
|
||||||
|
|
||||||
|
:param integer l: the key's length
|
||||||
|
:return: a string
|
||||||
|
"""
|
||||||
|
punctuation = """!#$%&()*+,-./:;<=>?@[]^_`{|}~"""
|
||||||
|
population = string.digits + string.ascii_letters + punctuation
|
||||||
|
while True:
|
||||||
|
key = "".join(random.sample(population * l, l))
|
||||||
|
if len(key) == l:
|
||||||
|
return key
|
||||||
|
|||||||
Reference in New Issue
Block a user