From 570c8e6bceffae88f521fff2a3c43d79fe768ec5 Mon Sep 17 00:00:00 2001 From: Graham Dumpleton Date: Thu, 28 Aug 2014 22:47:12 +1000 Subject: Add option to mod_wsgi express to allow for user authentication using a Python script. --- tests/auth.wsgi | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'tests') 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 [''] -- cgit v1.2.1