##// END OF EJS Templates
backported to stable #355 LDAP passwords stored
marcink -
r2005:ab0e122b default
parent child Browse files
Show More
@@ -76,8 +76,10 b' class PasswordGenerator(object):'
76 76 def __init__(self, passwd=''):
77 77 self.passwd = passwd
78 78
79 def gen_password(self, len, type):
80 self.passwd = ''.join([random.choice(type) for _ in xrange(len)])
79 def gen_password(self, length, type_=None):
80 if type_ is None:
81 type_ = self.ALPHABETS_FULL
82 self.passwd = ''.join([random.choice(type_) for _ in xrange(length)])
81 83 return self.passwd
82 84
83 85
@@ -211,9 +213,14 b' def authenticate(username, password):'
211 213 'email': get_ldap_attr('ldap_attr_email'),
212 214 }
213 215
214 if user_model.create_ldap(username, password, user_dn,
216 # don't store LDAP password since we don't need it. Override
217 # with some random generated password
218 _password = PasswordGenerator().gen_password(length=8)
219 # create this user on the fly if it doesn't exist in rhodecode
220 # database
221 if user_model.create_ldap(username, _password, user_dn,
215 222 user_attrs):
216 log.info('created new ldap user %s', username)
223 log.info('created new ldap user %s' % username)
217 224
218 225 return True
219 226 except (LdapUsernameError, LdapPasswordError,):
General Comments 0
You need to be logged in to leave comments. Login now