comparison rhodecode/lib/auth.py @ 1116:716911af91e1 beta

Added api_key into user, api key get's generated again after password change updated ini files
author Marcin Kuzminski <marcin@python-works.com>
date Sun, 06 Mar 2011 00:06:28 +0100
parents 520d27f40b51
children 6eb5bb24a948
comparison
equal deleted inserted replaced
1115:fcb5054937f6 1116:716911af91e1
26 26
27 import bcrypt 27 import bcrypt
28 import random 28 import random
29 import logging 29 import logging
30 import traceback 30 import traceback
31 31 import hashlib
32 from tempfile import _RandomNameSequence
32 from decorator import decorator 33 from decorator import decorator
33 34
34 from pylons import config, session, url, request 35 from pylons import config, session, url, request
35 from pylons.controllers.util import abort, redirect 36 from pylons.controllers.util import abort, redirect
36 from pylons.i18n.translation import _ 37 from pylons.i18n.translation import _
84 """Cryptographic function used for password hashing based on pybcrypt 85 """Cryptographic function used for password hashing based on pybcrypt
85 86
86 :param password: password to hash 87 :param password: password to hash
87 """ 88 """
88 return bcrypt.hashpw(password, bcrypt.gensalt(10)) 89 return bcrypt.hashpw(password, bcrypt.gensalt(10))
90
91 def generate_api_key(username, salt=None):
92 if salt is None:
93 salt = _RandomNameSequence().next()
94
95 return hashlib.sha1(username + salt).hexdigest()
89 96
90 def check_password(password, hashed): 97 def check_password(password, hashed):
91 return bcrypt.hashpw(password, hashed) == hashed 98 return bcrypt.hashpw(password, hashed) == hashed
92 99
93 def authfunc(environ, username, password): 100 def authfunc(environ, username, password):