Mercurial > hg > bitsyauth
comparison bitsyauth/__init__.py @ 52:aabc968611bc
STUB: bitsyauth/__init__.py
author | Jeff Hammel <k0scist@gmail.com> |
---|---|
date | Sun, 23 Feb 2014 17:08:13 -0800 |
parents | 54a53bbe5be9 |
children | d9e712cfd098 |
comparison
equal
deleted
inserted
replaced
51:12342551537b | 52:aabc968611bc |
---|---|
1 """ | |
2 bitsyauth: wrapper module for paste auth | |
3 """ | |
4 | |
1 import markup | 5 import markup |
2 import random | 6 import random |
3 import re | 7 import re |
4 import sys | 8 import sys |
5 | 9 |
26 _dictionary = [ i.strip() for i in _dictionary ] | 30 _dictionary = [ i.strip() for i in _dictionary ] |
27 _dictionary = [ i.lower() for i in _dictionary | 31 _dictionary = [ i.lower() for i in _dictionary |
28 if i.isalpha() and i > min_length ] | 32 if i.isalpha() and i > min_length ] |
29 globals()['dictionary'] = _dictionary | 33 globals()['dictionary'] = _dictionary |
30 return random.Random().choice(dictionary) | 34 return random.Random().choice(dictionary) |
35 | |
31 | 36 |
32 class BitsyAuthInnerWare(object): | 37 class BitsyAuthInnerWare(object): |
33 """inner auth; does login checking""" | 38 """inner auth; does login checking""" |
34 | 39 |
35 def __init__(self, app, passwords, newuser=None, site=None, realm=None): | 40 def __init__(self, app, passwords, newuser=None, site=None, realm=None): |
235 if error: | 240 if error: |
236 return { 'Name': 'Wrong username or password' } | 241 return { 'Name': 'Wrong username or password' } |
237 self.request.environ['REMOTE_USER'] = user | 242 self.request.environ['REMOTE_USER'] = user |
238 self.request.environ['paste.auth_tkt.set_user'](user) | 243 self.request.environ['paste.auth_tkt.set_user'](user) |
239 | 244 |
245 | |
240 ### join | 246 ### join |
241 | 247 |
242 def captcha_pre(self, word, key): | 248 def captcha_pre(self, word, key): |
243 """CAPTCHA with pre-formatted text""" | 249 """CAPTCHA with pre-formatted text""" |
244 return skimpyAPI.Pre(word, scale=1.2).data() | 250 return skimpyAPI.Pre(word, scale=1.2).data() |