Skip to content

Commit

Permalink
django 1.3 requires something in auth_backends
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeff Balogh committed Apr 1, 2011
1 parent 1c5f770 commit 6620ad5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
12 changes: 12 additions & 0 deletions apps/users/backends.py
Expand Up @@ -22,3 +22,15 @@ def get_user(self, user_id):
return User.objects.get(pk=user_id) return User.objects.get(pk=user_id)
except User.DoesNotExist: except User.DoesNotExist:
return None 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
2 changes: 1 addition & 1 deletion settings.py
Expand Up @@ -731,7 +731,7 @@ def read_only_mode(env):
env['DATABASES']['default'] = env['DATABASES'][slave] env['DATABASES']['default'] = env['DATABASES'][slave]


# No sessions without the database, so disable auth. # 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. # Add in the read-only middleware before csrf middleware.
extra = 'amo.middleware.ReadOnlyMiddleware' extra = 'amo.middleware.ReadOnlyMiddleware'
Expand Down

0 comments on commit 6620ad5

Please sign in to comment.