Add (crude) support for SPNEGO in the web interface
authorEvan Broder <broder@mit.edu>
Fri, 14 Nov 2008 08:39:21 +0000 (03:39 -0500)
committerEvan Broder <broder@mit.edu>
Fri, 14 Nov 2008 08:39:21 +0000 (03:39 -0500)
svn path=/trunk/packages/invirt-web/; revision=1642

code/main.py

index 551ed04..cf1424a 100755 (executable)
@@ -652,7 +652,18 @@ def show_error(op, username, fields, err, emsg, traceback):
 
 def getUser(environ):
     """Return the current user based on the SSL environment variables"""
-    return environ.get('REMOTE_USER', None)
+    user = environ.get('REMOTE_USER')
+    if user is None:
+        return
+    
+    if environ.get('AUTH_TYPE') == 'Negotiate':
+        # Convert the krb5 principal into a krb4 username
+        if not user.endswith('@%s' % config.authn[0].realm):
+            return
+        else:
+            return user.split('@')[0].replace('/', '.')
+    else:
+        return user
 
 def handler(username, state, path, fields):
     operation, path = pathSplit(path)