From: Thierry Parmentelat Date: Tue, 3 Sep 2013 14:46:08 +0000 (+0200) Subject: get rid of MyCustomBackend that had hard-wired user accounts X-Git-Tag: myslice-0.2-1~24^2~5 X-Git-Url: http://git.onelab.eu/?p=myslice.git;a=commitdiff_plain;h=71c5af2da6325002d0418468ebe9a1c2036a8549 get rid of MyCustomBackend that had hard-wired user accounts --- diff --git a/auth/backend.py b/auth/backend.py deleted file mode 100644 index 4c93676a..00000000 --- a/auth/backend.py +++ /dev/null @@ -1,40 +0,0 @@ -# import the User object -from django.contrib.auth.models import User - -import time - -# Name my backend 'MyCustomBackend' -class MyCustomBackend: - - hard_wired_users = { 'jean': '1234', - 'root': '2345', - 'jacques': '3456', - } - - - # Create an authentication method - # This is called by the standard Django login procedure - def authenticate(self, token=None): - username=token['username'] - password=token['password'] - users=MyCustomBackend.hard_wired_users - if username not in users: return None - if password != users[username]: return None - try: - # Check if the user exists in Django's local database - user = User.objects.get(email=username) - except User.DoesNotExist: - print 'creating django user',username - # Create a user in Django's local database - # warning: the trick here is pass current time as an id, and name as email - # create_user(username, email=None, password=None) - user = User.objects.create_user(time.time(), username, 'password-doesnt-matter') - - return user - - # Required for your backend to work properly - unchanged in most scenarios - def get_user(self, user_id): - try: - return User.objects.get(pk=user_id) - except User.DoesNotExist: - return None diff --git a/auth/views.py b/auth/views.py index f650c14e..6380cf2d 100644 --- a/auth/views.py +++ b/auth/views.py @@ -5,17 +5,15 @@ from django.shortcuts import render_to_response from django.contrib.auth import authenticate, login, logout from django.http import HttpResponseRedirect -from auth.backend import MyCustomBackend - from myslice.viewutils import topmenu_items, the_user from myslice.config import Config def login_user(request): state = "Please log in below..." username = password = '' - env={'hard_wired_users':MyCustomBackend.hard_wired_users, - 'manifold_url':Config.manifold_url, - } + env={ + 'manifold_url':Config.manifold_url, + } if request.POST: username = request.POST.get('username') diff --git a/myslice/settings.py b/myslice/settings.py index df4f6d7c..25c2a26e 100644 --- a/myslice/settings.py +++ b/myslice/settings.py @@ -231,7 +231,7 @@ LOGGING = { } } -AUTHENTICATION_BACKENDS = ( 'auth.backend.MyCustomBackend', 'auth.manifoldbackend.ManifoldBackend', ) +AUTHENTICATION_BACKENDS = ( 'auth.manifoldbackend.ManifoldBackend', ) ### the view to redirect malformed (i.e. with a wrong CSRF) incoming requests # without this setting django will return a 403 forbidden error, which is fine diff --git a/views/templates/view-login.html b/views/templates/view-login.html index 8d15f968..305b5c6d 100644 --- a/views/templates/view-login.html +++ b/views/templates/view-login.html @@ -6,18 +6,13 @@ {% block unfold2_main %}
@@ -37,6 +32,7 @@ testbeds including PlanetLab Europe, the NITOS wireless testbed, and other federated testbeds.

+

This UI server is connected to the manifold backend running at {{ manifold_url }}.

{% endblock unfold2_main %}