diff --git a/docs/conf.py b/docs/conf.py index 1f3c49a78efff567dacf8de5310f954c94c42af3..744c5cb6f1d455dbfed8ac853ab8a8312f29b6eb 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -64,9 +64,9 @@ copyright = u'2017, Alexandre Ferland' # built documents. # # The short X.Y version. -version = '1.1.2' +version = '1.2.0' # The full version, including alpha/beta/rc tags. -release = '1.1.2' +release = '1.2.0' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/docs/index.rst b/docs/index.rst index dcc2e90ea83c89e8268fa5253e35bb36f62263b8..7f4dbae653517a9e532f9d71d164e930266e527c 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -116,6 +116,9 @@ History Changes: +- 1.2.0 September 26, 2017 + - Changed get_group_members() and get_user_groups() returning strings instead of bytes in PY3. + - 1.1.2 July 17, 2017 - Merge GitHub PR `#30 <https://github.com/admiralobvious/flask-simpleldap/pull/30>`_, Fix for python3 diff --git a/flask_simpleldap/__init__.py b/flask_simpleldap/__init__.py index e7885c0aebac88ec272ad29e9eb0b23fba9acee8..82ae17fcd2326e51a2617ac8a7ca485cf5274ef6 100644 --- a/flask_simpleldap/__init__.py +++ b/flask_simpleldap/__init__.py @@ -150,10 +150,7 @@ class LDAP(object): return try: conn = self.initialize - if sys.version_info[0] > 2: - conn.simple_bind_s(user_dn, password) - else: - conn.simple_bind_s(user_dn.decode('utf-8'), password) + conn.simple_bind_s(user_dn.decode('utf-8'), password) return True except ldap.LDAPError: return @@ -248,6 +245,8 @@ class LDAP(object): current_app.config['LDAP_USER_GROUPS_FIELD']] result = [re.findall(b'(?:cn=|CN=)(.*?),', group)[0] for group in groups] + if sys.version_info[0] > 2: + result = [r.decode('utf-8') for r in result] return result except ldap.LDAPError as e: raise LDAPException(self.error(e.args)) @@ -272,6 +271,8 @@ class LDAP(object): records[0][1]: members = records[0][1][ current_app.config['LDAP_GROUP_MEMBERS_FIELD']] + if sys.version_info[0] > 2: + members = [m.decode('utf-8') for m in members] return members except ldap.LDAPError as e: raise LDAPException(self.error(e.args)) diff --git a/setup.py b/setup.py index 137a98e80711cf9896467ac83ae5975aafd22fd7..baed24c52efec1c554ab016d7695b1c067c0efd6 100644 --- a/setup.py +++ b/setup.py @@ -9,7 +9,7 @@ from setuptools import setup setup( name='Flask-SimpleLDAP', - version='1.1.2', + version='1.2.0', url='https://github.com/admiralobvious/flask-simpleldap', license='MIT', author='Alexandre Ferland',