From 08f146136a3d04239a75cb682203468193fbe87a Mon Sep 17 00:00:00 2001
From: admiralobvious <aferlandqc@gmail.com>
Date: Sun, 14 Jul 2019 19:19:36 -0400
Subject: [PATCH] merge outstanding PRs

---
 .travis.yml                  |  4 ++--
 LICENSE                      |  2 +-
 README.md                    | 14 +++++++++++++-
 flask_simpleldap/__init__.py | 13 +++++--------
 run.py                       | 20 ++++++++++++++++++++
 setup.py                     |  5 +++--
 6 files changed, 44 insertions(+), 14 deletions(-)
 create mode 100644 run.py

diff --git a/.travis.yml b/.travis.yml
index 78feec8..95851af 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -3,12 +3,12 @@ sudo: required
 dist: xenial
 python:
   - "2.7"
-  - "3.4"
   - "3.5"
   - "3.6"
   - "3.7"
 env:
-  - FLASK=1.0.2
+  - FLASK=1.1.1
+  - FLASK=1.0.4
   - FLASK=0.12.4
 install:
   - pip install Flask==$FLASK
diff --git a/LICENSE b/LICENSE
index de96633..89f8850 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,6 +1,6 @@
 The MIT License (MIT)
 
-Copyright (c) 2017 Alexandre Ferland
+Copyright (c) 2019 Alexandre Ferland
 
 Permission is hereby granted, free of charge, to any person obtaining a copy
 of this software and associated documentation files (the "Software"), to deal
diff --git a/README.md b/README.md
index 96dc713..e00e9a3 100644
--- a/README.md
+++ b/README.md
@@ -14,7 +14,7 @@ First, install Flask-SimpleLDAP:
     
 Flask-SimpleLDAP depends, and will install for you, recent versions of Flask
 (0.10.1 or later) and [pyldap](https://github.com/pyldap/pyldap). Flask-SimpleLDAP is compatible
-with and tested on Python 2.7, 3.4, 3.5 and 3.6.
+with and tested on Python 2.7, 3.5, 3.6 and 3.7.
 
 Next, add a ``LDAP`` instance to your code and at least the three
 required configuration options:
@@ -30,10 +30,16 @@ app.config['LDAP_PASSWORD'] = 'password'
 
 ldap = LDAP(app)
 
+
 @app.route('/ldap')
 @ldap.login_required
 def ldap_protected():
     return 'Success!'
+
+
+if __name__ == '__main__':
+    app.run()
+
 ```
 
 You can take a look at [examples/groups](examples/groups) for a more complete 
@@ -78,10 +84,16 @@ app.config['LDAP_GROUP_MEMBER_FILTER_FIELD'] = "cn"
 
 ldap = LDAP(app)
 
+
 @app.route('/ldap')
 @ldap.login_required
 def ldap_protected():
     return 'Success!'
+
+
+if __name__ == '__main__':
+    app.run()
+
 ```
 
 
diff --git a/flask_simpleldap/__init__.py b/flask_simpleldap/__init__.py
index 9c83ade..23b389c 100644
--- a/flask_simpleldap/__init__.py
+++ b/flask_simpleldap/__init__.py
@@ -75,9 +75,6 @@ class LDAP(object):
             if app.config['LDAP_{0}'.format(option)] is None:
                 raise LDAPException('LDAP_{0} cannot be None!'.format(option))
 
-        # Bind LDAP to app
-        app.ldap = self
-                
     @staticmethod
     def _set_custom_options(conn):
         options = current_app.config['LDAP_CUSTOM_OPTIONS']
@@ -175,13 +172,13 @@ class LDAP(object):
             if not dn_only:
                 fields = current_app.config['LDAP_USER_FIELDS']
             query_filter = query_filter or \
-                current_app.config['LDAP_USER_OBJECT_FILTER']
+                           current_app.config['LDAP_USER_OBJECT_FILTER']
             query = ldap_filter.filter_format(query_filter, (user,))
         elif group is not None:
             if not dn_only:
                 fields = current_app.config['LDAP_GROUP_FIELDS']
             query_filter = query_filter or \
-                current_app.config['LDAP_GROUP_OBJECT_FILTER']
+                           current_app.config['LDAP_GROUP_OBJECT_FILTER']
             query = ldap_filter.filter_format(query_filter, (group,))
         conn = self.bind
         try:
@@ -201,9 +198,9 @@ class LDAP(object):
                                 current_app.config['LDAP_OBJECTS_DN']]
                             return dn[0]
                 if type(records[0][1]) == 'dict':
-                	for k, v in list(records[0][1].items()):
-                    		result[k] = v
-                	return result
+                    for k, v in list(records[0][1].items()):
+                        result[k] = v
+                    return result
         except ldap.LDAPError as e:
             raise LDAPException(self.error(e.args))
 
diff --git a/run.py b/run.py
new file mode 100644
index 0000000..a6a54b5
--- /dev/null
+++ b/run.py
@@ -0,0 +1,20 @@
+from flask import Flask
+from flask_simpleldap import LDAP
+
+app = Flask(__name__)
+app.config['LDAP_BASE_DN'] = 'OU=users,dc=example,dc=org'
+app.config['LDAP_USERNAME'] = 'CN=user,OU=Users,DC=example,DC=org'
+app.config['LDAP_PASSWORD'] = 'password'
+
+ldap = LDAP(app)
+
+
+@app.route('/ldap')
+@ldap.login_required
+def ldap_protected():
+    return 'Success!'
+
+
+if __name__ == '__main__':
+    app.run()
+
diff --git a/setup.py b/setup.py
index 85c2314..2f5d8dc 100644
--- a/setup.py
+++ b/setup.py
@@ -9,7 +9,7 @@ from setuptools import setup
 
 setup(
     name='Flask-SimpleLDAP',
-    version='1.2.0',
+    version='1.3.0',
     url='https://github.com/admiralobvious/flask-simpleldap',
     license='MIT',
     author='Alexandre Ferland',
@@ -21,7 +21,7 @@ setup(
     include_package_data=True,
     platforms='any',
     install_requires=[
-        'Flask>=0.10.1',
+        'Flask>=0.12.4',
         'python-ldap'
     ],
     classifiers=[
@@ -33,6 +33,7 @@ setup(
         'Programming Language :: Python :: 3.4',
         'Programming Language :: Python :: 3.5',
         'Programming Language :: Python :: 3.6',
+        'Programming Language :: Python :: 3.7',
         'Topic :: Software Development :: Libraries :: Python Modules'
     ]
 )
-- 
GitLab