Permalink
Browse files

remove "Search Users" related code

  • Loading branch information...
1 parent 6ef6181 commit c7e1350c8bedb36eb9869e7be0c9c0814205bf47 @rmartinjak rmartinjak committed Mar 9, 2013
Showing with 4 additions and 67 deletions.
  1. +3 −32 sagenb/notebook/auth.py
  2. +1 −15 sagenb/notebook/server_conf.py
  3. +0 −20 sagenb/notebook/user_manager.py
View
@@ -7,9 +7,6 @@ class AuthMethod():
def __init__(self, conf):
self._conf = conf
- def user_lookup(self, search):
- raise NotImplementedError
-
def check_user(self, username):
raise NotImplementedError
@@ -31,10 +28,6 @@ class LdapAuth(AuthMethod):
1.2) find the ldap object matching username.
2) if 1 succeeds, try simple bind with the supplied user DN and password
-
- User lookup:
- wildcard-search all configured "user lookup attributes" for the given
- search string
"""
def _require_ldap(default_return):
@@ -60,7 +53,7 @@ def wrapped_f(self, *args, **kwargs):
def __init__(self, conf):
AuthMethod.__init__(self, conf)
- def _ldap_search(self, query, attrlist=None):
+ def _ldap_search(self, query, attrlist=None, sizelimit=20):
"""
runs any ldap query passed as arg
"""
@@ -81,8 +74,8 @@ def _ldap_search(self, query, attrlist=None):
ldap.SCOPE_SUBTREE,
filterstr=query,
attrlist=attrlist,
- timeout=self._conf['ldap_timeout'],
- sizelimit=self._conf['ldap_sizelimit'])
+ timeout=self._conf['ldap_timeout'])
+ sizelimit=sizelimit)
except ldap.LDAPError, e:
print 'LDAP Error: %s' % str(e)
return []
@@ -107,28 +100,6 @@ def _get_ldapuser(self, username, attrlist=None):
# (len(result) will probably always be 0 or 1)
return result[0] if len(result) == 1 else (None, None)
- @_require_ldap(None)
- def user_lookup(self, search):
- from ldap.filter import filter_format
-
- uname_attrib = self._conf['ldap_username_attrib']
- lookup_attribs = self._conf['ldap_lookup_attribs']
-
- # build ldap OR query
- query = '(|%s)' % ''.join(
- filter_format('(%s=*%s*)', [a, search]) for a in lookup_attribs)
-
- result = self._ldap_search(query, attrlist=[str(uname_attrib)])
-
- # return a list of usernames
- unames = []
- for dn, attribs in result:
- uname_list = attribs.get(uname_attrib, None)
- if uname_list:
- # use only the first item of the attribute list
- unames.append(uname_list[0])
- return unames
-
@_require_ldap(False)
def check_user(self, username):
# LDAP is NOT case sensitive while sage is, so only allow lowercase
@@ -52,9 +52,7 @@
'ldap_bindpw': 'secret',
'ldap_gssapi': False,
'ldap_username_attrib': 'cn',
- 'ldap_lookup_attribs': ['cn', 'sn', 'givenName', 'mail'],
'ldap_timeout': 5,
- 'ldap_sizelimit': 30,
}
G_APPEARANCE = _('Appearance')
@@ -238,24 +236,12 @@
GROUP : G_LDAP,
TYPE : T_STRING,
},
- 'ldap_lookup_attribs': {
- POS : 8,
- DESC: _('Attributes for user lookup'),
- GROUP : G_LDAP,
- TYPE : T_LIST,
- },
'ldap_timeout': {
- POS : 9,
+ POS : 8,
DESC: _('Query timeout (seconds)'),
GROUP : G_LDAP,
TYPE : T_INTEGER,
},
- 'ldap_sizelimit': {
- POS : 9,
- DESC: _('Max. number of search results'),
- GROUP : G_LDAP,
- TYPE : T_INTEGER,
- },
}
@@ -113,14 +113,6 @@ def user(self, username):
raise KeyError, "no user '%s'"%username
- def user_lookup(self, search):
- r = [x for x in self.users().keys() if search in x]
- try:
- r += [u for u in self._user_lookup(search) if u not in r]
- except AttributeError:
- pass
- return r
-
def valid_login_names(self):
"""
Return a list of users that can log in.
@@ -543,18 +535,6 @@ def _check_password(self, username, password):
return False
- def _user_lookup(self, search):
- """
- Returns a list of usernames that are found when calling user_lookup on all enabled auth methods
- """
- r = set()
- for a in self._auth_methods:
- if self._conf[a]:
- names = self._auth_methods[a].user_lookup(search)
- if names:
- r = r.union(names)
- return list(r)
-
class OpenIDUserManager(ExtAuthUserManager):
def __init__(self, accounts=True, conf=None):
"""

0 comments on commit c7e1350

Please sign in to comment.