Hi, I believe this patch might help with the MD5/SHA1 migration "issue" of user passwords. It adds a auth backend for the user.prefs file, the result is that the first time a user authenticates with Pootle the password matched is used to insert the new user.
Please test. This was hacked up in 2 minutes. Also feel free to adjust the wording. Flávio Martins
Index: Pootle/settings.py =================================================================== --- Pootle/settings.py (revisão 10756) +++ Pootle/settings.py (cópia de trabalho) @@ -139,11 +139,16 @@ PREFSFILE = pootle_home('pootle.prefs') +USERPREFSFILE = pootle_home('user.prefs') + PODIRECTORY = pootle_home('po') # Use the commented definition to authenticate first with Mozilla's LDAP system and then to fall back # to Django's authentication system. #AUTHENTICATION_BACKENDS = ('auth.ldap_backend.LdapBackend', 'django.contrib.auth.backends.ModelBackend',) +# Use this commented definition if you want to accept the login information from a previous version of Pootle. +# Pootle will authenticate the user using the user.prefs file. The user must not be added manually. +#AUTHENTICATION_BACKENDS = ('django.contrib.auth.backends.ModelBackend', 'auth.prefs_backend.PrefsBackend',) AUTHENTICATION_BACKENDS = ('django.contrib.auth.backends.ModelBackend',) # LDAP Setup Index: Pootle/auth/prefs_backend.py =================================================================== --- Pootle/auth/prefs_backend.py (revisão 0) +++ Pootle/auth/prefs_backend.py (revisão 0) @@ -0,0 +1,41 @@ +from django.conf import settings +from django.contrib.auth.models import User +from jToolkit import prefs +from jToolkit.web import session + +class PrefsBackend(object): + """ + Authenticate against a Pootle installation user.prefs file. + + Use the login name, and a hash of the password. + + This authentication backend can be used for migration purposes. + + """ + + def check_password(self, raw_password, enc_password): + return session.md5hexdigest(raw_password) == enc_password + + def authenticate(self, username=None, password=None): + p = prefs.PrefsParser() + p.parsefile(settings.USERPREFSFILE) + login_valid = p.__hasattr__(username) + pwd_valid = self.check_password(password, + p.__getattr__(username).__getattr__('passwdhash')) + if login_valid and pwd_valid: + try: + user = User.objects.get(username=username) + except User.DoesNotExist: + # Create a new user. Note that we can set password + # to anything. We will set the password to be the + # same as the one in the prefs since the hash matches. + user = User(username=username, password=password) + user.save() + return user + return None + + def get_user(self, user_id): + try: + return User.objects.get(pk=user_id) + except User.DoesNotExist: + return None
------------------------------------------------------------------------------
_______________________________________________ Translate-pootle mailing list Translate-pootle@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/translate-pootle