mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-28 15:42:25 +00:00
Unification du mot de passe
This commit is contained in:
parent
ec2c705ec0
commit
8a68f92ac5
1 changed files with 19 additions and 0 deletions
|
@ -3,6 +3,10 @@ from users.models import User, School, Adherent
|
||||||
from django.db.models import F, Value
|
from django.db.models import F, Value
|
||||||
from django.db.models.functions import Concat
|
from django.db.models.functions import Concat
|
||||||
|
|
||||||
|
from re2o.login import hashNT, makeSecret
|
||||||
|
|
||||||
|
import os, random, string
|
||||||
|
|
||||||
class Command(BaseCommand):
|
class Command(BaseCommand):
|
||||||
help="Anonymize the data in the database in order to use them on critical servers (dev, personnal...). Every information will be overwritten using non-personnal informations. This script must follow any modification of the database."
|
help="Anonymize the data in the database in order to use them on critical servers (dev, personnal...). Every information will be overwritten using non-personnal informations. This script must follow any modification of the database."
|
||||||
|
|
||||||
|
@ -47,5 +51,20 @@ class Command(BaseCommand):
|
||||||
a.update(comment=Concat(Value('commentaire of '), 'id'))
|
a.update(comment=Concat(Value('commentaire of '), 'id'))
|
||||||
self.stdout.write(self.style.SUCCESS('done ...'))
|
self.stdout.write(self.style.SUCCESS('done ...'))
|
||||||
|
|
||||||
|
self.stdout.write('Unification du mot de passe...')
|
||||||
|
# Define the password
|
||||||
|
chars = string.ascii_letters + string.digits + '!@#$%^&*()'
|
||||||
|
taille = 20
|
||||||
|
random.seed = (os.urandom(1024))
|
||||||
|
password = ""
|
||||||
|
for i in range(taille):
|
||||||
|
password+=random.choice(chars)
|
||||||
|
|
||||||
|
self.stdout.write(self.style.HTTP_NOT_MODIFIED('The password will be: {}'.format(password)))
|
||||||
|
|
||||||
|
a.update(pwd_ntlm = hashNT(password))
|
||||||
|
a.update(password = makeSecret(password))
|
||||||
|
self.stdout.write(self.style.SUCCESS('done...'))
|
||||||
|
|
||||||
|
|
||||||
self.stdout.write("Data anonymized!")
|
self.stdout.write("Data anonymized!")
|
||||||
|
|
Loading…
Reference in a new issue