[sagenb] 58/179: remove "Search Users" related code
felix salfelder
felix-guest at moszumanska.debian.org
Tue May 6 12:05:10 UTC 2014
This is an automated email from the git hooks/post-receive script.
felix-guest pushed a commit to branch master
in repository sagenb.
commit c7e1350c8bedb36eb9869e7be0c9c0814205bf47
Author: Robin Martinjak <rob at rmartinjak.de>
Date: Sat Mar 9 20:03:25 2013 +0100
remove "Search Users" related code
---
sagenb/notebook/auth.py | 35 +++--------------------------------
sagenb/notebook/server_conf.py | 16 +---------------
sagenb/notebook/user_manager.py | 20 --------------------
3 files changed, 4 insertions(+), 67 deletions(-)
diff --git a/sagenb/notebook/auth.py b/sagenb/notebook/auth.py
index 3d576ae..2a1aa3e 100644
--- a/sagenb/notebook/auth.py
+++ b/sagenb/notebook/auth.py
@@ -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 @@ class LdapAuth(AuthMethod):
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 @@ class LdapAuth(AuthMethod):
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 @@ class LdapAuth(AuthMethod):
# (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
diff --git a/sagenb/notebook/server_conf.py b/sagenb/notebook/server_conf.py
index 580efd5..39b3072 100644
--- a/sagenb/notebook/server_conf.py
+++ b/sagenb/notebook/server_conf.py
@@ -52,9 +52,7 @@ defaults = {'word_wrap_cols':72,
'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 @@ defaults_descriptions = {
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,
- },
}
diff --git a/sagenb/notebook/user_manager.py b/sagenb/notebook/user_manager.py
index f7815cd..994f17a 100644
--- a/sagenb/notebook/user_manager.py
+++ b/sagenb/notebook/user_manager.py
@@ -113,14 +113,6 @@ class UserManager(object):
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 @@ class ExtAuthUserManager(SimpleUserManager):
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):
"""
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/sagenb.git
More information about the debian-science-commits
mailing list