Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Added a seperate wsgi auth script to hack around WSGIAuthGroupScript …

…not working.
  • Loading branch information...
commit 76234bf1d027106cd2d38db361e7c9f982a29eba 1 parent 4ac9970
Jacob Kaplan-Moss authored January 28, 2011

Showing 1 changed file with 51 additions and 0 deletions. Show diff stats Hide diff stats

  1. 51  wsgi-scripts/svnauth.wsgi
51  wsgi-scripts/svnauth.wsgi
... ...
@@ -0,0 +1,51 @@
  1
+"""
  2
+This file's a hack working around WSGIAuthGroupScript not working.
  3
+"""
  4
+
  5
+import os
  6
+import sys 
  7
+import site 
  8
+
  9
+#
  10
+# Bootstrap
  11
+#
  12
+
  13
+SITE_PACKAGES = '/home/www/djangoproject.com/lib/python2.6/site-packages'
  14
+
  15
+# Remember original sys.path.
  16
+prev_sys_path = list(sys.path) 
  17
+
  18
+# Add each new site-packages directory.
  19
+site.addsitedir(SITE_PACKAGES)
  20
+
  21
+# Reorder sys.path so new directories at the front.
  22
+new_sys_path = [] 
  23
+for item in list(sys.path): 
  24
+    if item not in prev_sys_path: 
  25
+        new_sys_path.append(item) 
  26
+        sys.path.remove(item) 
  27
+sys.path[:0] = new_sys_path 
  28
+
  29
+# Bootstrap Django
  30
+here = os.path.dirname(__file__)
  31
+parent = os.path.dirname(here)
  32
+sys.path.append(parent)
  33
+os.environ['DJANGO_SETTINGS_MODULE'] = 'django_website.settings.www'
  34
+
  35
+#
  36
+# WSGI auth handler
  37
+#
  38
+from django import db
  39
+from django.contrib.auth.models import User
  40
+
  41
+def check_password(environ, user, password):
  42
+    try:
  43
+        user = User.objects.get(username=user, is_active=True)
  44
+        if user.check_password(password):
  45
+            # HACK ALERT!
  46
+            return 'committers' in [g.name.lower() for g in user.groups.all()]
  47
+        return False
  48
+    except User.DoesNotExist:
  49
+        return None
  50
+    finally:
  51
+        db.connection.close()

0 notes on commit 76234bf

Please sign in to comment.
Something went wrong with that request. Please try again.