get rid of MyCustomBackend that had hard-wired user accounts
authorThierry Parmentelat <thierry.parmentelat@inria.fr>
Tue, 3 Sep 2013 14:46:08 +0000 (16:46 +0200)
committerThierry Parmentelat <thierry.parmentelat@inria.fr>
Tue, 3 Sep 2013 14:46:08 +0000 (16:46 +0200)
auth/backend.py [deleted file]
auth/views.py
myslice/settings.py
views/templates/view-login.html

diff --git a/auth/backend.py b/auth/backend.py
deleted file mode 100644 (file)
index 4c93676..0000000
+++ /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
index f650c14..6380cf2 100644 (file)
@@ -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')
index df4f6d7..25c2a26 100644 (file)
@@ -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
index 8d15f96..305b5c6 100644 (file)
@@ -6,18 +6,13 @@
 
 {% block unfold2_main %}
 <!--
-<code> This page is currently connected to two authentication systems:</code>
+<code> This page is currently connected to one authentication system:</code>
 <ul>
 <li> A manifold server, located at <code>{{ manifold_url }}</code>, (configured in <code>myslice/config.py</code>), and</li>
-<li>
-as a proof of concept, a set of hardwired user accounts, see <code>auth/backend.py</code> for more details. However these won't of course have the ability to run real queries at the backend so it's more for testing login and all this.
-Currently hard wired users are:
-<ul>
-  {% for k,v in hard_wired_users.iteritems %}
-  <li class='well'> Name= <code>{{ k }}</code>, Password= <code>{{ v }}</code> </li>
-  {% endfor %}
 </ul>
-</li></ul>
+<p>
+as a proof of concept, a set of hardwired user accounts used to be available but as these would not let you do anything valuable with the backend it is now turned off.
+</p>
 -->
 <link rel="stylesheet" type="text/css" href="{{STATIC_URL}}/css/register.css" />
 <div style='padding: 20px;'>
@@ -37,6 +32,7 @@ testbeds including PlanetLab Europe, the NITOS wireless testbed, and other
 federated testbeds.
   </p>
   <div class="item-separator"></div>
+<p>This UI server is connected to the manifold backend running at <code>{{ manifold_url }}</code>.</p>
 </div>
 
 {% endblock unfold2_main %}