Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added a seperate wsgi auth script to hack around WSGIAuthGroupScript …

…not working.
  • Loading branch information...
commit 76234bf1d027106cd2d38db361e7c9f982a29eba 1 parent 4ac9970
Jacob Kaplan-Moss jacobian authored
Showing with 51 additions and 0 deletions.
  1. +51 −0 wsgi-scripts/svnauth.wsgi
51 wsgi-scripts/svnauth.wsgi
View
@@ -0,0 +1,51 @@
+"""
+This file's a hack working around WSGIAuthGroupScript not working.
+"""
+
+import os
+import sys
+import site
+
+#
+# Bootstrap
+#
+
+SITE_PACKAGES = '/home/www/djangoproject.com/lib/python2.6/site-packages'
+
+# Remember original sys.path.
+prev_sys_path = list(sys.path)
+
+# Add each new site-packages directory.
+site.addsitedir(SITE_PACKAGES)
+
+# Reorder sys.path so new directories at the front.
+new_sys_path = []
+for item in list(sys.path):
+ if item not in prev_sys_path:
+ new_sys_path.append(item)
+ sys.path.remove(item)
+sys.path[:0] = new_sys_path
+
+# Bootstrap Django
+here = os.path.dirname(__file__)
+parent = os.path.dirname(here)
+sys.path.append(parent)
+os.environ['DJANGO_SETTINGS_MODULE'] = 'django_website.settings.www'
+
+#
+# WSGI auth handler
+#
+from django import db
+from django.contrib.auth.models import User
+
+def check_password(environ, user, password):
+ try:
+ user = User.objects.get(username=user, is_active=True)
+ if user.check_password(password):
+ # HACK ALERT!
+ return 'committers' in [g.name.lower() for g in user.groups.all()]
+ return False
+ except User.DoesNotExist:
+ return None
+ finally:
+ db.connection.close()
Please sign in to comment.
Something went wrong with that request. Please try again.