diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 6736f18..52b7d63 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,7 +1,7 @@ Changelog ========= -0.7.1 (2018-03-16) +0.7.1 (2018-04-07) ------------------ * Add setting FORCE_ATTRIBUTE_VALUE_AS_LIST diff --git a/Pipfile.lock b/Pipfile.lock index c42a0bf..41e824a 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -3,19 +3,6 @@ "hash": { "sha256": "a98c93ecd227b3cd991674d2f829b752b2c9816a18279af6630ffb7c7aed95be" }, - "host-environment-markers": { - "implementation_name": "cpython", - "implementation_version": "3.6.4", - "os_name": "posix", - "platform_machine": "x86_64", - "platform_python_implementation": "CPython", - "platform_release": "4.15.8-300.fc27.x86_64", - "platform_system": "Linux", - "platform_version": "#1 SMP Fri Mar 9 18:11:36 UTC 2018", - "python_full_version": "3.6.4", - "python_version": "3.6", - "sys_platform": "linux" - }, "pipfile-spec": 6, "requires": {}, "sources": [ @@ -39,6 +26,7 @@ "sha256:0749df235e3ff61ac108f69ac178c9770caeaccad2509cb762ce1f65570a8856", "sha256:49f44461237b69ecd901cc7ce66feea0319b9158743dd27a2899962ab214dac1" ], + "index": "pypi", "version": "==0.12.2" }, "itsdangerous": { @@ -56,13 +44,14 @@ }, "ldap3": { "hashes": [ - "sha256:ed3d5ac156f61ff06df0ef499569a970b544011a3e836296bd731e0da92f10c0", "sha256:44c900354823218597e71de864c81d40be81b6f5fc6bcc109a2130a89a8f4fc8", "sha256:7912093b2501a04b7a2fb9042f2504a8664c3543498186c6ef0421cbd2eb7331", + "sha256:c4133692ff33e0a96780e6bd40f450545251d3e1786557c61d091eaeb2ef9138", "sha256:d257500ea9b5af0ecca8c319fc3fb9b758f9f5e4b8441032cb681dee026c646a", "sha256:e8fe0d55a8cecb725748c831ffac2873df94c05b2d7eb867ea167c0500bbc6a8", - "sha256:c4133692ff33e0a96780e6bd40f450545251d3e1786557c61d091eaeb2ef9138" + "sha256:ed3d5ac156f61ff06df0ef499569a970b544011a3e836296bd731e0da92f10c0" ], + "index": "pypi", "version": "==2.4.1" }, "markupsafe": { @@ -73,32 +62,33 @@ }, "pyasn1": { "hashes": [ - "sha256:f81c96761fca60d64b1c9b79ec2e40cf9495a745cf570613079ef324aeb9672b", - "sha256:7d626683e3d792cccc608da02498aff37ab4f3dafd8905d6bf755d11f9b26b43", - "sha256:e85895087905c65b5b594eb91f7522664c85545b147d5f4d4e7b1b07da8dcbdc", + "sha256:0d7f6e959fe53f3960a23d73f35e1fce61348b30915b6664309ca756de7c1f89", "sha256:5a0db897b311d265cde49615cf783f1c78613138605cdd0f907ecfa5b2aba3ee", - "sha256:d5cd6ed995dba16fad0c521cfe31cd2d68400b53fcc2bce93326829be73ab6d1", + "sha256:758cb50abddc03e4563fd9e7f03db56e3e87b58c0bd01247360326e5c0c7ffa5", + "sha256:7d626683e3d792cccc608da02498aff37ab4f3dafd8905d6bf755d11f9b26b43", "sha256:a7efe807c4b83a859e2735c692b92ed7b567cfddc4163763412920041d876c2b", "sha256:b5a9ca48055b9a20f6d1b3d68e38692e5431c86a0f99ea602e61294e891fee5b", "sha256:c07d6e587b2f928366b1f67c09bda026a3e6fcc99e80a744dc67f8fca3895626", + "sha256:d258b0a71994f7770599835249cece1caef3c70def868c4915e6e5ca49b67d15", + "sha256:d5cd6ed995dba16fad0c521cfe31cd2d68400b53fcc2bce93326829be73ab6d1", "sha256:d84c2aea3cf43780e9e6a19f4e4dddee9f6976519020e64e47c57e5c7a8c3dd2", - "sha256:758cb50abddc03e4563fd9e7f03db56e3e87b58c0bd01247360326e5c0c7ffa5", - "sha256:0d7f6e959fe53f3960a23d73f35e1fce61348b30915b6664309ca756de7c1f89", - "sha256:d258b0a71994f7770599835249cece1caef3c70def868c4915e6e5ca49b67d15" + "sha256:e85895087905c65b5b594eb91f7522664c85545b147d5f4d4e7b1b07da8dcbdc", + "sha256:f81c96761fca60d64b1c9b79ec2e40cf9495a745cf570613079ef324aeb9672b" ], "version": "==0.4.2" }, "six": { "hashes": [ - "sha256:832dc0e10feb1aa2c68dcc57dbb658f1c7e65b9b61af69048abc87a2db00a0eb", - "sha256:70e8a77beed4562e7f14fe23a786b54f6296e34344c23bc42f07b15018ff98e9" + "sha256:70e8a77beed4562e7f14fe23a786b54f6296e34344c23bc42f07b15018ff98e9", + "sha256:832dc0e10feb1aa2c68dcc57dbb658f1c7e65b9b61af69048abc87a2db00a0eb" ], + "index": "pypi", "version": "==1.11.0" }, "werkzeug": { "hashes": [ - "sha256:d5da73735293558eb1651ee2fddc4d0dedcfa06538b8813a2e20011583c9e49b", - "sha256:c3fd7a7d41976d9f44db327260e263132466836cef6f91512889ed60ad26557c" + "sha256:c3fd7a7d41976d9f44db327260e263132466836cef6f91512889ed60ad26557c", + "sha256:d5da73735293558eb1651ee2fddc4d0dedcfa06538b8813a2e20011583c9e49b" ], "version": "==0.14.1" } @@ -106,8 +96,8 @@ "develop": { "attrs": { "hashes": [ - "sha256:a17a9573a6f475c99b551c0e0a812707ddda1ec9653bed04c13841404ed6f450", - "sha256:1c7960ccfd6a005cd9f7ba884e6316b5e430a3f1a6c37c5f87d8b43f83b54ec9" + "sha256:1c7960ccfd6a005cd9f7ba884e6316b5e430a3f1a6c37c5f87d8b43f83b54ec9", + "sha256:a17a9573a6f475c99b551c0e0a812707ddda1ec9653bed04c13841404ed6f450" ], "version": "==17.4.0" }, @@ -120,17 +110,18 @@ }, "chardet": { "hashes": [ - "sha256:fc323ffcaeaed0e0a02bf4d117757b98aed530d9ed4531e3e15460124c106691", - "sha256:84ab92ed1c4d4f16916e05906b6b75a6c0fb5db821cc65e70cbd64a3e2a5eaae" + "sha256:84ab92ed1c4d4f16916e05906b6b75a6c0fb5db821cc65e70cbd64a3e2a5eaae", + "sha256:fc323ffcaeaed0e0a02bf4d117757b98aed530d9ed4531e3e15460124c106691" ], "version": "==3.0.4" }, "docker": { "hashes": [ - "sha256:651c6feea03f5f12c823d3adc1db34ecf21e05965908e580d1b651b8c2269e9e", - "sha256:462165ca6367f802280684ab44e581cd2efba8995d78d07ea994e42194927c3b" + "sha256:0d698c3dc4df66c988de5df21a62cdc3450de2fa8523772779e5e23799c41f43", + "sha256:f1a512a0dbc518459159d4584572ebc6de2cc8006b2e376eff02cfae7d72aff0" ], - "version": "==3.1.1" + "index": "pypi", + "version": "==3.2.1" }, "docker-pycreds": { "hashes": [ @@ -141,11 +132,19 @@ }, "idna": { "hashes": [ - "sha256:8c7309c718f94b3a625cb648ace320157ad16ff131ae0af362c9f21b80ef6ec4", - "sha256:2c6a5de3089009e3da7c5dde64a141dbc8551d5b7f6cf4ed7c2568d0cc520a8f" + "sha256:2c6a5de3089009e3da7c5dde64a141dbc8551d5b7f6cf4ed7c2568d0cc520a8f", + "sha256:8c7309c718f94b3a625cb648ace320157ad16ff131ae0af362c9f21b80ef6ec4" ], "version": "==2.6" }, + "more-itertools": { + "hashes": [ + "sha256:0dd8f72eeab0d2c3bd489025bb2f6a1b8342f9b198f6fc37b52d15cfa4531fea", + "sha256:11a625025954c20145b37ff6309cd54e39ca94f72f6bb9576d1195db6fa2442e", + "sha256:c9ce7eccdcb901a2c75d326ea134e0886abfbea5f93e91cc95de9507c0816c44" + ], + "version": "==4.1.0" + }, "pluggy": { "hashes": [ "sha256:7f8ae7f5bdf75671a718d2daf0a64b7885f74510bcd98b1a0bb420eb9a9d0cff" @@ -154,17 +153,18 @@ }, "py": { "hashes": [ - "sha256:8cca5c229d225f8c1e3085be4fcf306090b00850fefad892f9d96c7b6e2f310f", - "sha256:ca18943e28235417756316bfada6cd96b23ce60dd532642690dcfdaba988a76d" + "sha256:29c9fab495d7528e80ba1e343b958684f4ace687327e6f789a94bf3d1915f881", + "sha256:983f77f3331356039fdd792e9220b7b8ee1aa6bd2b25f567a963ff1de5a64f6a" ], - "version": "==1.5.2" + "version": "==1.5.3" }, "pytest": { "hashes": [ - "sha256:062027955bccbc04d2fcd5d79690947e018ba31abe4c90b2c6721abec734261b", - "sha256:117bad36c1a787e1a8a659df35de53ba05f9f3398fb9e4ac17e80ad5903eb8c5" + "sha256:6266f87ab64692112e5477eba395cfedda53b1933ccd29478e671e73b420c19c", + "sha256:fae491d1874f199537fd5872b5e1f0e74a009b979df9d53d1553fd03da1703e1" ], - "version": "==3.4.2" + "index": "pypi", + "version": "==3.5.0" }, "requests": { "hashes": [ @@ -175,9 +175,10 @@ }, "six": { "hashes": [ - "sha256:832dc0e10feb1aa2c68dcc57dbb658f1c7e65b9b61af69048abc87a2db00a0eb", - "sha256:70e8a77beed4562e7f14fe23a786b54f6296e34344c23bc42f07b15018ff98e9" + "sha256:70e8a77beed4562e7f14fe23a786b54f6296e34344c23bc42f07b15018ff98e9", + "sha256:832dc0e10feb1aa2c68dcc57dbb658f1c7e65b9b61af69048abc87a2db00a0eb" ], + "index": "pypi", "version": "==1.11.0" }, "urllib3": { diff --git a/README.rst b/README.rst index f9a26a3..a946829 100644 --- a/README.rst +++ b/README.rst @@ -39,13 +39,19 @@ Your configuration should be declared within your Flask config. Sample configura LDAP_TLS_VERSION = ssl.PROTOCOL_TLSv1_2 # default: PROTOCOL_TLSv1 LDAP_CERT_PATH = '/etc/openldap/certs' -TIf you want to allways get the entry attribute value as a list, instead of a string if only one item is in the attribute set: +If you want to always get any entry attribute value as a list, instead of a string if only one item is in the attribute list, then set: .. code-block:: python FORCE_ATTRIBUTE_VALUE_AS_LIST = True -Create the ldap instance within your application: +Default is ``False`` and will return a string if only one item is in the attribute list. + + +Setup +----- + +Create the LDAP instance in your application. .. code-block:: python @@ -159,7 +165,7 @@ Authenticate with Client with app.app_context(): retval = ldap.authenticate(username, password, attribute, - basedn, search_filter') + basedn, search_filter) if not retval: return 'Invalid credentials.' return 'Welcome %s.' % username @@ -168,13 +174,14 @@ Authenticate with Client Bind as user ------------ -To bind as user for the current request save a new connection to ``flask.g.ldap_conn``: +To bind as user for the current request instance a new connection from ``flask.g.ldap_conn``: .. code-block:: python g.ldap_conn = ldap.connect(userdn, password) user = User.query.get(userdn) + Unit Test ---------