nextcloud: Use secrets module generate passwords

- It choose highest security random number automatically.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
Sunil Mohan Adapa 2024-04-05 16:23:03 -07:00 committed by James Valleroy
parent 547db1608b
commit d7b05385c6
No known key found for this signature in database
GPG Key ID: 77C0C75E7B650808

View File

@ -3,7 +3,7 @@
import json
import pathlib
import random
import secrets
import shutil
import string
import subprocess
@ -304,8 +304,7 @@ def _drop_database():
def _generate_secret_key(length=64, chars=None):
"""Generate a new random secret key for use with Nextcloud."""
chars = chars or (string.ascii_letters + string.digits)
rand = random.SystemRandom()
return ''.join(rand.choice(chars) for _ in range(length))
return ''.join(secrets.choice(chars) for _ in range(length))
def _set_maintenance_mode(on: bool):