Attachment '0001-PATCH-LDAPAuth-allow-authentication-to-continue.patch'
Download 1 From bc7ca56f41194a33cc82b261238a224b6a634aa2 Mon Sep 17 00:00:00 2001
2 From: Martin Wilck <martin.wilck@ts.fujitsu.com>
3 Date: Fri, 25 May 2012 16:03:07 +0200
4 Subject: [PATCH 1/2] PATCH: [LDAPAuth] allow authentication to continue
5
6 This patch removes use of CancelLogin when bad LDAP credentials
7 were encountered, allowing other auth methods to continue after
8 LDAP failure.
9
10 Furthermore, in the case of LDAP bind failure, the cases with
11 and with out bind_dn are more cleanly distinguished.
12 ---
13 auth/ldap_login.py | 10 ++++++++--
14 1 files changed, 8 insertions(+), 2 deletions(-)
15
16 diff --git a/auth/ldap_login.py b/auth/ldap_login.py
17 index 29dba6e..ba93098 100644
18 --- a/auth/ldap_login.py
19 +++ b/auth/ldap_login.py
20 @@ -27,7 +27,7 @@ except ImportError, err:
21 raise
22
23 from MoinMoin import user
24 -from MoinMoin.auth import BaseAuth, CancelLogin, ContinueLogin
25 +from MoinMoin.auth import BaseAuth, ContinueLogin
26
27
28 class LDAPAuth(BaseAuth):
29 @@ -242,8 +242,14 @@ class LDAPAuth(BaseAuth):
30 logging.debug("creating user object with name %r email %r alias %r" % (username, email, aliasname))
31
32 except ldap.INVALID_CREDENTIALS, err:
33 + if self.bind_once:
34 + if self.report_invalid_credentials:
35 + return ContinueLogin(user_obj,
36 + message=_("Invalid username or password."))
37 + else:
38 + return ContinueLogin(user_obj)
39 logging.debug("invalid credentials (wrong password?) for dn %r (username: %r)" % (dn, username))
40 - return CancelLogin(_("Invalid username or password."))
41 + return ContinueLogin(user_obj, _("Bind to LDAP server %(server)s failed." % {'server': server}))
42
43 if u and self.autocreate:
44 logging.debug("calling create_or_update to autocreate user %r" % u.name)
45 --
46 1.7.7.6
Attached Files
To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.You are not allowed to attach a file to this page.