Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix browserid autologin

Fixes #278
  • Loading branch information...
commit 8c55e83a689c918f5a2146e905ef33280d6d8c60 1 parent cc283d1
@willkg authored
Showing with 8 additions and 46 deletions.
  1. +0 −44 src/richard/base/auth.py
  2. +8 −2 src/richard/config/settings.py
View
44 src/richard/base/auth.py
@@ -1,44 +0,0 @@
-# richard -- video index system
-# Copyright (C) 2012, 2013, 2014, 2015 richard contributors. See AUTHORS.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-from django.conf import settings
-from django.contrib.auth.models import User
-
-
-class AutoLoginBackend(object):
- """Allow login without credentials.
-
- This is used to work on richard when a missing internet connection doesn't
- allow authentication with browserid (persona).
-
- `BROWSERID_AUTOLOGIN` is the email address to use to select a user.
- """
-
- def authenticate(self, **kwargs):
- email = getattr(settings, 'BROWSERID_AUTOLOGIN', None)
- if not email:
- return None
-
- try:
- return User.objects.get(email=email)
- except User.DoesNotExist:
- return None
-
- def get_user(self, user_id):
- try:
- return User.objects.get(pk=user_id)
- except User.DoesNotExist:
- return None
View
10 src/richard/config/settings.py
@@ -380,12 +380,18 @@ class Dev(Base):
INSTALLED_APPS = Base.INSTALLED_APPS + ('eadred',)
AUTHENTICATION_BACKENDS = (
- 'richard.base.auth.AutoLoginBackend', # DON'T use this in Production!
+ 'django_browserid.auth.AutoLoginBackend', # DON'T use this in Production!
'django_browserid.auth.BrowserIDBackend',
)
BROWSERID_AUDIENCES = ['http://localhost:8000', 'http://127.0.0.1:8000']
- BROWSERID_AUTOLOGIN = ''
+
+ # To enable autologin, use environment variables:
+ # export BROWSERID_AUTOLOGIN_EMAIL="joe@example.com"
+ # export BROWSERID_AUTOLOGIN_ENABLED=1
+ # ./manage.py runserver
+ BROWSERID_AUTOLOGIN_EMAIL = values.Value('')
+ BROWSERID_AUTOLOGIN_ENABLED = values.BooleanValue(False)
class Prod(Base):
Please sign in to comment.
Something went wrong with that request. Please try again.