##// END OF EJS Templates
fixed issues with not unique emails when using ldap or container auth.
marcink -
r1690:6944b124 beta
parent child Browse files
Show More
@@ -43,8 +43,7 b' class AuthLdap(object):'
43 def __init__(self, server, base_dn, port=389, bind_dn='', bind_pass='',
43 def __init__(self, server, base_dn, port=389, bind_dn='', bind_pass='',
44 tls_kind='PLAIN', tls_reqcert='DEMAND', ldap_version=3,
44 tls_kind='PLAIN', tls_reqcert='DEMAND', ldap_version=3,
45 ldap_filter='(&(objectClass=user)(!(objectClass=computer)))',
45 ldap_filter='(&(objectClass=user)(!(objectClass=computer)))',
46 search_scope='SUBTREE',
46 search_scope = 'SUBTREE', attr_login = 'uid'):
47 attr_login='uid'):
48 self.ldap_version = ldap_version
47 self.ldap_version = ldap_version
49 ldap_server_type = 'ldap'
48 ldap_server_type = 'ldap'
50
49
@@ -60,7 +59,7 b' class AuthLdap(object):'
60 self.LDAP_SERVER_ADDRESS = server
59 self.LDAP_SERVER_ADDRESS = server
61 self.LDAP_SERVER_PORT = port
60 self.LDAP_SERVER_PORT = port
62
61
63 #USE FOR READ ONLY BIND TO LDAP SERVER
62 # USE FOR READ ONLY BIND TO LDAP SERVER
64 self.LDAP_BIND_DN = bind_dn
63 self.LDAP_BIND_DN = bind_dn
65 self.LDAP_BIND_PASS = bind_pass
64 self.LDAP_BIND_PASS = bind_pass
66
65
@@ -149,6 +149,10 b' class UserModel(BaseModel):'
149 :param attrs:
149 :param attrs:
150 """
150 """
151 if self.get_by_username(username, case_insensitive=True) is None:
151 if self.get_by_username(username, case_insensitive=True) is None:
152
153 # autogenerate email for container account without one
154 generate_email = lambda usr: '%s@container_auth.account' % usr
155
152 try:
156 try:
153 new_user = User()
157 new_user = User()
154 new_user.username = username
158 new_user.username = username
@@ -156,7 +160,7 b' class UserModel(BaseModel):'
156 new_user.api_key = generate_api_key(username)
160 new_user.api_key = generate_api_key(username)
157 new_user.email = attrs['email']
161 new_user.email = attrs['email']
158 new_user.active = attrs.get('active', True)
162 new_user.active = attrs.get('active', True)
159 new_user.name = attrs['name']
163 new_user.name = attrs['name'] or generate_email(username)
160 new_user.lastname = attrs['lastname']
164 new_user.lastname = attrs['lastname']
161
165
162 self.sa.add(new_user)
166 self.sa.add(new_user)
General Comments 0
You need to be logged in to leave comments. Login now