Ticket #18038: 18038-wip.patch
File 18038-wip.patch, 3.4 KB (added by , 13 years ago) |
---|
-
docs/topics/auth.txt
1840 1840 ADMIN_PASSWORD = 'sha1$4e987$afbcf42e21bd417fb71db8c66b321e9fc33051de' 1841 1841 """ 1842 1842 1843 supports_inactive_user = False1844 1845 1843 def authenticate(self, username=None, password=None): 1846 1844 login_valid = (settings.ADMIN_LOGIN == username) 1847 1845 pwd_valid = check_password(password, settings.ADMIN_PASSWORD) … … 1940 1938 anonymous users to have permissions to do something while inactive 1941 1939 authenticated users do not. 1942 1940 1943 To enable this on your own backend, you must set the class attribute1944 ``supports_inactive_user`` to ``True``.1945 1941 1946 A nonexisting ``supports_inactive_user`` attribute will raise a1947 ``PendingDeprecationWarning`` if used in Django 1.3. In Django 1.4, this1948 warning will be updated to a ``DeprecationWarning`` which will be displayed1949 loudly. Additionally ``supports_inactive_user`` will be set to ``False``.1950 Django 1.5 will assume that every backend supports inactive users being1951 passed to the authorization methods.1952 1953 1954 1942 Handling object permissions 1955 1943 --------------------------- 1956 1944 -
django/contrib/auth/__init__.py
1 from warnings import warn2 1 from django.core.exceptions import ImproperlyConfigured 3 2 from django.utils.importlib import import_module 4 3 from django.contrib.auth.signals import user_logged_in, user_logged_out … … 21 20 except AttributeError: 22 21 raise ImproperlyConfigured('Module "%s" does not define a "%s" authentication backend' % (module, attr)) 23 22 24 if not hasattr(cls, 'supports_inactive_user'):25 warn("Authentication backends without a `supports_inactive_user` attribute are deprecated. Please define it in %s." % cls,26 DeprecationWarning)27 cls.supports_inactive_user = False28 23 return cls() 29 24 30 25 def get_backends(): -
django/contrib/auth/backends.py
5 5 """ 6 6 Authenticates against django.contrib.auth.models.User. 7 7 """ 8 supports_inactive_user = True9 8 10 9 # TODO: Model, login attribute name and password attribute name should be 11 10 # configurable. -
django/contrib/auth/models.py
200 200 anon = user.is_anonymous() 201 201 active = user.is_active 202 202 for backend in auth.get_backends(): 203 if anon or active or backend.supports_inactive_user:203 if anon or active: 204 204 if hasattr(backend, "has_perm"): 205 205 if obj is not None: 206 206 if backend.has_perm(user, perm, obj): … … 215 215 anon = user.is_anonymous() 216 216 active = user.is_active 217 217 for backend in auth.get_backends(): 218 if anon or active or backend.supports_inactive_user:218 if anon or active: 219 219 if hasattr(backend, "has_module_perms"): 220 220 if backend.has_module_perms(user, app_label): 221 221 return True