From: Evan Broder <broder@mit.edu>
Date: Fri, 14 Nov 2008 08:39:21 +0000 (-0500)
Subject: Add (crude) support for SPNEGO in the web interface
X-Git-Tag: 0.0.9~8
X-Git-Url: http://xvm.mit.edu/gitweb/invirt/packages/invirt-web.git/commitdiff_plain/c12260eef39e630fde25d58cbf1dab44e4b1a605?ds=sidebyside

Add (crude) support for SPNEGO in the web interface

svn path=/trunk/packages/invirt-web/; revision=1642
---

diff --git a/code/main.py b/code/main.py
index 551ed04..cf1424a 100755
--- a/code/main.py
+++ b/code/main.py
@@ -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)