18 lines
487 B
Python
18 lines
487 B
Python
from crypt import crypt
|
|
import os
|
|
|
|
|
|
def htpasswd(username, password, request):
|
|
settings = request.registry.settings
|
|
file = settings['biforst.auth']
|
|
if not os.path.isfile(file):
|
|
return None
|
|
users = {}
|
|
with open(file) as f:
|
|
for line in f:
|
|
login, pwd = line.split(':')
|
|
users[login] = pwd.rstrip('\n')
|
|
if username in users and crypt(password, users[username]) == users[username]:
|
|
return [Authenticated]
|
|
return None
|