]> snippets.scripts.mit.edu Git - Scripts/git/.git/commitdiff
Set a password of UNUSABLE_PASSWORD
authorAlex Dehnert <adehnert@mit.edu>
Mon, 24 Dec 2012 08:28:00 +0000 (03:28 -0500)
committerMIT Association of Student Activities <asa@mit.edu>
Mon, 24 Dec 2012 08:28:00 +0000 (03:28 -0500)
* 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

index 07715314850892522676527b6f8da5ab990df9e3..dc3fefa36ca5b2c0e28cf07b59b7b98062ebced1 100644 (file)
@@ -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"