summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorGraham Dumpleton <Graham.Dumpleton@gmail.com>2014-08-28 22:47:12 +1000
committerGraham Dumpleton <Graham.Dumpleton@gmail.com>2014-08-28 22:47:12 +1000
commit570c8e6bceffae88f521fff2a3c43d79fe768ec5 (patch)
tree79c3ae3039ddee3e7e1290e63d1b04e5f39b7ac0 /tests
parent004458851c3b2149ca4bd76ff8907024eb3e1fac (diff)
downloadmod_wsgi-570c8e6bceffae88f521fff2a3c43d79fe768ec5.tar.gz
Add option to mod_wsgi express to allow for user authentication using a Python script.
Diffstat (limited to 'tests')
-rw-r--r--tests/auth.wsgi26
1 files changed, 25 insertions, 1 deletions
diff --git a/tests/auth.wsgi b/tests/auth.wsgi
index 39b6304..58e655b 100644
--- a/tests/auth.wsgi
+++ b/tests/auth.wsgi
@@ -1,6 +1,30 @@
def check_password(environ, user, password):
+ print('USER', user, environ['REQUEST_URI'])
if user == 'spy':
if password == 'secret':
- return 'grumpy'
+ return True
return False
+ elif user == 'witness':
+ if password == 'secret':
+ return 'protected'
+ return False
+ return None
return None
+
+import md5
+
+def get_realm_hash(environ, user, realm):
+ print('USER', user, environ['REQUEST_URI'])
+ if user == 'spy':
+ value = md5.new()
+ # user:realm:password
+ value.update('%s:%s:%s' % (user, realm, 'secret'))
+ hash = value.hexdigest()
+ return hash
+ return None
+
+def groups_for_user(environ, user):
+ print('GROUP', user, environ['REQUEST_URI'])
+ if user == 'spy':
+ return ['secret-agents']
+ return ['']