From c6b6a6b9fa3c428729b369296476b6839a04dbf7 Mon Sep 17 00:00:00 2001 From: Alex Dehnert Date: Mon, 24 Dec 2012 03:28:00 -0500 Subject: [PATCH] Set a password of UNUSABLE_PASSWORD * Changes ScriptsRemoteUserBackend's configure_user method to set the default password to UNUSABLE_PASSWORD instead of ScriptsSSLAuth. UNUSABLE_PASSWORD displays in the admin as "Password: None", instead of an ugly error message. This should fix "Unknown password hashing algorithm" errors for users correctly created in the future. (ASA-#132) * Adds a migration to change current users with passwords of "" or "ScriptsSSLAuth" to a password of UNUSABLE_PASSWORD ("!"). This will fix ASA-#132 and the symptoms of ASA-#133 for already-existent users. --- __init__.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/__init__.py b/__init__.py index 0771531..dc3fefa 100644 --- a/__init__.py +++ b/__init__.py @@ -4,8 +4,9 @@ import tempfile import ldap import ldap.filter -from django.contrib.auth.middleware import RemoteUserMiddleware from django.contrib.auth.backends import RemoteUserBackend +from django.contrib.auth.hashers import UNUSABLE_PASSWORD +from django.contrib.auth.middleware import RemoteUserMiddleware from django.contrib.auth.views import login from django.contrib.auth import REDIRECT_FIELD_NAME from django.http import HttpResponseRedirect @@ -82,7 +83,7 @@ class ScriptsRemoteUserBackend(RemoteUserBackend): return username def configure_user(self, user, ): username = user.username - user.password = "ScriptsSSLAuth" + user.password = UNUSABLE_PASSWORD con = ldap.open('ldap-too.mit.edu') con.simple_bind_s("", "") dn = "dc=mit,dc=edu" -- 2.45.0