Authentication mechanism changed. I don't use Django's builtin

passwords encryption anymore because the default format is something
like : <algo>$<salt>$<password>
I really think this format is not compatible with external softwares
so I use simple hashes.
This commit is contained in:
tonio
2009-03-27 09:25:09 +01:00
parent 80f17440cc
commit ab5b8d96c3
5 changed files with 59 additions and 2 deletions
+23
View File
@@ -0,0 +1,23 @@
from django.contrib.auth.models import User
from mailng.admin.models import Mailbox
import md5
class SimpleBackend:
def authenticate(self, username=None, password=None):
try:
user = User.objects.get(username=username)
except User.DoesNotExist:
return None
try:
mb = Mailbox.objects.get(full_address=username)
except Exception:
return None
if mb.password != md5.new(password).hexdigest():
return None
return user
def get_user(self, user_id):
try:
return User.objects.get(pk=user_id)
except User.DoesNotExist:
return None