Skip to content
Snippets Groups Projects
Commit ae9eecff authored by Alexandre Ferland's avatar Alexandre Ferland
Browse files

return strings instead of bytes for py3

parent 63b0bab9
No related branches found
No related tags found
No related merge requests found
...@@ -64,9 +64,9 @@ copyright = u'2017, Alexandre Ferland' ...@@ -64,9 +64,9 @@ copyright = u'2017, Alexandre Ferland'
# built documents. # built documents.
# #
# The short X.Y version. # The short X.Y version.
version = '1.1.2' version = '1.2.0'
# The full version, including alpha/beta/rc tags. # 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 # The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages. # for a list of supported languages.
......
...@@ -116,6 +116,9 @@ History ...@@ -116,6 +116,9 @@ History
Changes: 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 - 1.1.2 July 17, 2017
- Merge GitHub PR `#30 <https://github.com/admiralobvious/flask-simpleldap/pull/30>`_, - Merge GitHub PR `#30 <https://github.com/admiralobvious/flask-simpleldap/pull/30>`_,
Fix for python3 Fix for python3
......
...@@ -150,9 +150,6 @@ class LDAP(object): ...@@ -150,9 +150,6 @@ class LDAP(object):
return return
try: try:
conn = self.initialize 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 return True
except ldap.LDAPError: except ldap.LDAPError:
...@@ -248,6 +245,8 @@ class LDAP(object): ...@@ -248,6 +245,8 @@ class LDAP(object):
current_app.config['LDAP_USER_GROUPS_FIELD']] current_app.config['LDAP_USER_GROUPS_FIELD']]
result = [re.findall(b'(?:cn=|CN=)(.*?),', group)[0] result = [re.findall(b'(?:cn=|CN=)(.*?),', group)[0]
for group in groups] for group in groups]
if sys.version_info[0] > 2:
result = [r.decode('utf-8') for r in result]
return result return result
except ldap.LDAPError as e: except ldap.LDAPError as e:
raise LDAPException(self.error(e.args)) raise LDAPException(self.error(e.args))
...@@ -272,6 +271,8 @@ class LDAP(object): ...@@ -272,6 +271,8 @@ class LDAP(object):
records[0][1]: records[0][1]:
members = records[0][1][ members = records[0][1][
current_app.config['LDAP_GROUP_MEMBERS_FIELD']] current_app.config['LDAP_GROUP_MEMBERS_FIELD']]
if sys.version_info[0] > 2:
members = [m.decode('utf-8') for m in members]
return members return members
except ldap.LDAPError as e: except ldap.LDAPError as e:
raise LDAPException(self.error(e.args)) raise LDAPException(self.error(e.args))
......
...@@ -9,7 +9,7 @@ from setuptools import setup ...@@ -9,7 +9,7 @@ from setuptools import setup
setup( setup(
name='Flask-SimpleLDAP', name='Flask-SimpleLDAP',
version='1.1.2', version='1.2.0',
url='https://github.com/admiralobvious/flask-simpleldap', url='https://github.com/admiralobvious/flask-simpleldap',
license='MIT', license='MIT',
author='Alexandre Ferland', author='Alexandre Ferland',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment