diff --git a/dev_requirements.txt b/dev_requirements.txt index 355d97b0aa4604aa77c46ff2e198a4681797ff39..5395c698ea4f280e892acbee8cddf88d9e664295 100644 --- a/dev_requirements.txt +++ b/dev_requirements.txt @@ -1 +1,3 @@ -pyldap==2.4.25.1 +-r requirements.txt +Sphinx==1.4.3 + diff --git a/docs/conf.py b/docs/conf.py index 1c9772584df401f3d8a8e4313d3daf8519e849d3..49867afd54c755cfc0a0b51be8000e082ca57901 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -63,9 +63,9 @@ copyright = u'2016, Alexandre Ferland' # built documents. # # The short X.Y version. -version = '1.0.0' +version = '1.1.0' # The full version, including alpha/beta/rc tags. -release = '1.0.0' +release = '1.1.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 e39c74bdb9315ddc4d04615cd895a1c57dc62ed1..eacb4dd81b87c260e76332e758aaa8d249cf9fb9 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -96,6 +96,8 @@ directives: Default: '*' ``LDAP_GROUP_MEMBER_FILTER_FIELD`` The group member filter field to use when using OpenLDAP. Default: '*' +``LDAP_CUSTOM_OPTIONS`` ``dict`` of ldap options you want to set in this format: {option: value}. + Default: ``None`` ================================== ================================================================ @@ -114,6 +116,10 @@ History Changes: +- 1.1.0 June 7, 2016 + + - Add the ability the pass any valid pyldap config options via the LDAP_CUSTOM_OPTIONS configuration directive. + - 1.0.1 June 5, 2016 - Fix ldap filter import. diff --git a/examples/blueprints/blueprints/config.py b/examples/blueprints/blueprints/config.py index a7353cdf8960644abec99413c6f81d37d4de9f97..8156f297e4aa3f2932c80f9cf51451a2635e374a 100644 --- a/examples/blueprints/blueprints/config.py +++ b/examples/blueprints/blueprints/config.py @@ -1,3 +1,6 @@ +import ldap + + class BaseConfig(object): PROJECT = 'foo' SECRET_KEY = 'dev key' @@ -9,3 +12,4 @@ class BaseConfig(object): LDAP_USERNAME = 'CN=user,OU=Users,DC=example,DC=org' LDAP_PASSWORD = 'password' LDAP_LOGIN_VIEW = 'core.login' + LDAP_CUSTOM_OPTIONS = {ldap.OPT_REFERRALS: 0} diff --git a/examples/groups/app.py b/examples/groups/app.py index 61e74b5e0ada310426b4e0225d413520445c5646..747d6065ffeee7b0961829898c4283e5577d3985 100644 --- a/examples/groups/app.py +++ b/examples/groups/app.py @@ -1,3 +1,4 @@ +import ldap as l from flask import Flask, g, request, session, redirect, url_for from flask_simpleldap import LDAP @@ -9,6 +10,7 @@ app.config['LDAP_HOST'] = 'ldap.example.org' 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' +app.config['LDAP_CUSTOM_OPTIONS'] = {l.OPT_REFERRALS: 0} ldap = LDAP(app) diff --git a/flask_simpleldap/__init__.py b/flask_simpleldap/__init__.py index bb701dd07cac9383175b289cd39c08aa32870091..72403008fc35859fcf26aeb0a21b62bf083ee9a1 100644 --- a/flask_simpleldap/__init__.py +++ b/flask_simpleldap/__init__.py @@ -59,7 +59,7 @@ class LDAP(object): app.config.setdefault('LDAP_OPENLDAP', False) app.config.setdefault('LDAP_GROUP_MEMBER_FILTER', '*') app.config.setdefault('LDAP_GROUP_MEMBER_FILTER_FIELD', '*') - app.config.setdefault('LDAP_CUSTOM_OPTIONS', {}) + app.config.setdefault('LDAP_CUSTOM_OPTIONS', None) if app.config['LDAP_USE_SSL'] or app.config['LDAP_USE_TLS']: ldap.set_option(ldap.OPT_X_TLS_REQUIRE_CERT, @@ -77,9 +77,9 @@ class LDAP(object): @staticmethod def _set_custom_options(conn): - options = current_app.config['LDAP_OPTIONS'] + options = current_app.config['LDAP_CUSTOM_OPTIONS'] if options: - for k, v in options.values(): + for k, v in options.items(): conn.set_option(k, v) return conn diff --git a/requirements.txt b/requirements.txt index dfb153191723255eb00f1b98233a035ae190277f..3f54c81367df8391da0555f6c32170de69658cc2 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,4 @@ Flask==0.11 -mock==2.0.0 +mock==2.0.0 # for ci +pyldap==2.4.25.1 + diff --git a/setup.py b/setup.py index 063199019c20292dbf398cd90f3d33b20434c5d5..4ab62db389525fd646ed2f299362a9bf207c295f 100644 --- a/setup.py +++ b/setup.py @@ -9,7 +9,7 @@ from setuptools import setup setup( name='Flask-SimpleLDAP', - version='1.0.1', + version='1.1.0', url='https://github.com/admiralobvious/flask-simpleldap', license='MIT', author='Alexandre Ferland',