labs-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject svn commit: r1523256 - in /labs/panopticon: src/asf/data/ldap.py tests/test_ldap.py
Date Sat, 14 Sep 2013 14:27:25 GMT
Author: adc
Date: Sat Sep 14 14:27:24 2013
New Revision: 1523256

URL: http://svn.apache.org/r1523256
Log:
Check password code

Modified:
    labs/panopticon/src/asf/data/ldap.py
    labs/panopticon/tests/test_ldap.py

Modified: labs/panopticon/src/asf/data/ldap.py
URL: http://svn.apache.org/viewvc/labs/panopticon/src/asf/data/ldap.py?rev=1523256&r1=1523255&r2=1523256&view=diff
==============================================================================
--- labs/panopticon/src/asf/data/ldap.py (original)
+++ labs/panopticon/src/asf/data/ldap.py Sat Sep 14 14:27:24 2013
@@ -35,6 +35,18 @@ LDAP_BASE = 'ou=people,dc=apache,dc=org'
 log = getLogger(__name__)
 
 
+def check_user_password(username, password):
+    if not username or not password:
+        return False
+    cnx = _ldap_cnx()
+    try:
+        cnx.simple_bind_s('uid=%s,ou=people,dc=apache,dc=org' % username, password)
+    except ldap.INVALID_CREDENTIALS:
+        return False
+    else:
+        return True
+
+
 class LDAP(object):
     """
       Read-only LDAP access to ASF's Active Directory Server.

Modified: labs/panopticon/tests/test_ldap.py
URL: http://svn.apache.org/viewvc/labs/panopticon/tests/test_ldap.py?rev=1523256&r1=1523255&r2=1523256&view=diff
==============================================================================
--- labs/panopticon/tests/test_ldap.py (original)
+++ labs/panopticon/tests/test_ldap.py Sat Sep 14 14:27:24 2013
@@ -19,7 +19,7 @@
 
 from nose.tools import assert_equals, assert_raises
 
-from asf.data.ldap import LDAP
+from asf.data.ldap import LDAP, check_user_password
 
 
 def test_find_by_username():
@@ -54,3 +54,6 @@ def test_find_by_common_name():
     assert_equals(['Alan Cabrera'], result['cn'])
 
     assert ldap.is_valid_account('adc')
+
+def test_check_user_password():
+    assert not check_user_password('adc', 'SECRET')



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@labs.apache.org
For additional commands, e-mail: commits-help@labs.apache.org


Mime
View raw message