##// END OF EJS Templates
fixes issue #78, ldap makes user validation caseInsensitive...
marcink -
r741:54684e07 beta
parent child Browse files
Show More
@@ -103,6 +103,13 b' def authfunc(environ, username, password'
103
103
104
104
105 else:
105 else:
106
107 #since ldap is searching in case insensitive check if this user is still
108 #not in our system
109 username = username.lower()
110 if user_model.get_by_username(username, cache=False) is not None:
111 return False
112
106 from rhodecode.model.settings import SettingsModel
113 from rhodecode.model.settings import SettingsModel
107 ldap_settings = SettingsModel().get_ldap_settings()
114 ldap_settings = SettingsModel().get_ldap_settings()
108
115
@@ -110,6 +117,7 b' def authfunc(environ, username, password'
110 # FALLBACK TO LDAP AUTH IN ENABLE
117 # FALLBACK TO LDAP AUTH IN ENABLE
111 #======================================================================
118 #======================================================================
112 if ldap_settings.get('ldap_active', False):
119 if ldap_settings.get('ldap_active', False):
120
113 kwargs = {
121 kwargs = {
114 'server':ldap_settings.get('ldap_host', ''),
122 'server':ldap_settings.get('ldap_host', ''),
115 'base_dn':ldap_settings.get('ldap_base_dn', ''),
123 'base_dn':ldap_settings.get('ldap_base_dn', ''),
@@ -214,8 +222,8 b' def fill_perms(user):'
214
222
215 #default global
223 #default global
216 default_global_perms = sa.query(UserToPerm)\
224 default_global_perms = sa.query(UserToPerm)\
217 .filter(UserToPerm.user == sa.query(User).filter(User.username ==
225 .filter(UserToPerm.user == sa.query(User)\
218 'default').one())
226 .filter(User.username == 'default').one())
219
227
220 for perm in default_global_perms:
228 for perm in default_global_perms:
221 user.permissions['global'].add(perm.permission.permission_name)
229 user.permissions['global'].add(perm.permission.permission_name)
@@ -67,7 +67,7 b' def ValidUsername(edit, old_data):'
67 old_un = UserModel().get(old_data.get('user_id')).username
67 old_un = UserModel().get(old_data.get('user_id')).username
68
68
69 if old_un != value or not edit:
69 if old_un != value or not edit:
70 if UserModel().get_by_username(value, cache=False):
70 if UserModel().get_by_username(value.lower(), cache=False):
71 raise formencode.Invalid(_('This username already exists') ,
71 raise formencode.Invalid(_('This username already exists') ,
72 value, state)
72 value, state)
73
73
@@ -244,6 +244,8 b' class ValidPath(formencode.validators.Fa'
244 def UniqSystemEmail(old_data):
244 def UniqSystemEmail(old_data):
245 class _UniqSystemEmail(formencode.validators.FancyValidator):
245 class _UniqSystemEmail(formencode.validators.FancyValidator):
246 def to_python(self, value, state):
246 def to_python(self, value, state):
247 value = value.lower()
248 #TODO:write test for MixedCase scenarios
247 if old_data.get('email') != value:
249 if old_data.get('email') != value:
248 sa = meta.Session()
250 sa = meta.Session()
249 try:
251 try:
@@ -260,6 +262,7 b' def UniqSystemEmail(old_data):'
260
262
261 class ValidSystemEmail(formencode.validators.FancyValidator):
263 class ValidSystemEmail(formencode.validators.FancyValidator):
262 def to_python(self, value, state):
264 def to_python(self, value, state):
265 value = value.lower()
263 sa = meta.Session
266 sa = meta.Session
264 try:
267 try:
265 user = sa.query(User).filter(User.email == value).scalar()
268 user = sa.query(User).filter(User.email == value).scalar()
General Comments 0
You need to be logged in to leave comments. Login now