From e9f7884f68a0b1e3e5c06df4a0ffb362b21d74c6 Mon Sep 17 00:00:00 2001 From: Marcio Mazza Date: Tue, 27 Feb 2018 17:35:06 -0300 Subject: [PATCH] =?UTF-8?q?Completa=20migra=C3=A7=C3=A3o=20de=20senhas=20d?= =?UTF-8?q?o=20zope?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sapl/hashers.py | 2 ++ sapl/legacy/migracao_usuarios.py | 2 ++ 2 files changed, 4 insertions(+) diff --git a/sapl/hashers.py b/sapl/hashers.py index a514f8f19..e80642def 100644 --- a/sapl/hashers.py +++ b/sapl/hashers.py @@ -44,6 +44,8 @@ ZOPE_SHA1_PREFIX = '{SSHA}' def zope_encoded_password_to_django(encoded): + "Migra um hash de senha do zope para uso com o ZopeSHA1PasswordHasher" + if encoded.startswith(ZOPE_SHA1_PREFIX): data = encoded[len(ZOPE_SHA1_PREFIX):] salt = get_salt_from_zope_sha1(data) diff --git a/sapl/legacy/migracao_usuarios.py b/sapl/legacy/migracao_usuarios.py index 591f08b20..39d6df4e9 100644 --- a/sapl/legacy/migracao_usuarios.py +++ b/sapl/legacy/migracao_usuarios.py @@ -1,6 +1,7 @@ import yaml from django.contrib.auth.models import Group, User +from sapl.hashers import zope_encoded_password_to_django from sapl.settings import MEDIA_ROOT PERFIL_LEGADO_PARA_NOVO = {legado: Group.objects.get(name=novo) @@ -83,6 +84,7 @@ def migra_usuarios(): for nome, senha, perfis in usuarios: usuario = User.objects.get_or_create(username=nome)[0] + usuario.password = zope_encoded_password_to_django(senha) for perfil in perfis: if perfil in ADMINISTRADORES: # Manager