Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

django 1.3 requires something in auth_backends

  • Loading branch information...
commit 6620ad5a9e3aa3adc2e80ac7cb0e05d06c077ebc 1 parent 1c5f770
Jeff Balogh authored
Showing with 13 additions and 1 deletion.
  1. +12 −0 apps/users/backends.py
  2. +1 −1  settings.py
View
12 apps/users/backends.py
@@ -22,3 +22,15 @@ def get_user(self, user_id):
return User.objects.get(pk=user_id)
except User.DoesNotExist:
return None
+
+
+class NoAuthForYou(object):
+ """An authentication backend for read-only mode."""
+ supports_anonymous_user = False
+ supports_object_permissions = False
+
+ def authenticate(self, *args, **kw):
+ return None
+
+ def get_user(self, *args, **kw):
+ return None
View
2  settings.py
@@ -731,7 +731,7 @@ def read_only_mode(env):
env['DATABASES']['default'] = env['DATABASES'][slave]
# No sessions without the database, so disable auth.
- env['AUTHENTICATION_BACKENDS'] = ()
+ env['AUTHENTICATION_BACKENDS'] = ('users.backends.NoAuthForYou',)
# Add in the read-only middleware before csrf middleware.
extra = 'amo.middleware.ReadOnlyMiddleware'
Please sign in to comment.
Something went wrong with that request. Please try again.