New upstream version 1.5.1
Michael Fladischer
3 years ago
0 | [flake8] | |
1 | ||
2 | max-line-length = 120 | |
3 | # W503: 'and' on start of line | |
4 | ignore = W503 | |
5 | ||
6 | ; vim:set ft=dosini: |
0 | 0 | ChangeLog |
1 | 1 | ========= |
2 | ||
3 | 1.5.1 (2020-10-12) | |
4 | ------------------ | |
5 | ||
6 | *Bugfix:* | |
7 | ||
8 | * Fix empty wheel (missing nested code) | |
9 | ||
10 | ||
11 | 1.5.0 (2020-10-10) | |
12 | ------------------ | |
13 | ||
14 | *New:* | |
15 | ||
16 | * Add support for Django >= 3.1 | |
17 | ||
18 | *Removed:* | |
19 | ||
20 | * Drop support for Django < 2.2 | |
21 | * Drop support for Python < 3.6 | |
22 | ||
2 | 23 | |
3 | 24 | 1.4.0 (2019-07-11) |
4 | 25 | ------------------ |
0 | 0 | include AUTHORS ChangeLog CODE_OF_CONDUCT.md CONTRIBUTING.rst LICENSE README.rst |
1 | include requirements*.txt | |
2 | 1 | |
3 | 2 | graft ldapdb |
4 | 3 | graft tests |
7 | 6 | global-exclude *.py[cod] __pycache__ .*swp |
8 | 7 | prune .github |
9 | 8 | |
10 | include Makefile manage_dev.py tox.ini .flake8 | |
9 | include Makefile manage_dev.py tox.ini |
6 | 6 | -Wignore::PendingDeprecationWarning:imp \ |
7 | 7 | -Wignore::DeprecationWarning:imp \ |
8 | 8 | -Wignore::PendingDeprecationWarning:distutils \ |
9 | -Wignore::DeprecationWarning:distutils | |
9 | -Wignore::DeprecationWarning:distutils \ | |
10 | -Wignore::ImportWarning: | |
10 | 11 | |
11 | 12 | default: |
12 | 13 | |
13 | 14 | install: |
14 | ||
15 | 15 | python setup.py install |
16 | 16 | |
17 | 17 | clean: |
19 | 19 | find . -type f -path '*/__pycache__/*' -delete |
20 | 20 | find . -type d -empty -delete |
21 | 21 | |
22 | update: | |
22 | upgrade: | |
23 | 23 | pip install --upgrade pip setuptools |
24 | pip install -r requirements_dev.txt | |
24 | pip install --upgrade -e .[dev] | |
25 | 25 | pip freeze |
26 | 26 | |
27 | 27 | release: |
28 | 28 | fullrelease |
29 | 29 | |
30 | 30 | |
31 | .PHONY: default install clean update release | |
31 | .PHONY: default install clean upgrade release | |
32 | 32 | |
33 | 33 | testall: |
34 | 34 | tox |
41 | 41 | lint: flake8 isort check-manifest |
42 | 42 | |
43 | 43 | flake8: |
44 | flake8 --config .flake8 $(PACKAGE) $(TESTS_DIR) | |
44 | flake8 $(PACKAGE) $(TESTS_DIR) | |
45 | 45 | |
46 | 46 | isort: |
47 | isort $(PACKAGE) $(TESTS_DIR) --recursive --check-only --diff --project $(PACKAGE) --project $(TESTS_DIR) | |
47 | isort $(PACKAGE) $(TESTS_DIR) --check-only --diff --project $(PACKAGE) --project $(TESTS_DIR) | |
48 | 48 | |
49 | 49 | check-manifest: |
50 | 50 | check-manifest |
0 | Metadata-Version: 1.2 | |
0 | Metadata-Version: 2.1 | |
1 | 1 | Name: django-ldapdb |
2 | Version: 1.4.0 | |
3 | Summary: An LDAP database backend for Django | |
2 | Version: 1.5.1 | |
3 | Summary: A LDAP database backend for Django | |
4 | 4 | Home-page: https://github.com/django-ldapdb/django-ldapdb |
5 | Author: Jeremy Laine | |
5 | Author: Jeremy Lainé | |
6 | 6 | Author-email: jeremy.laine@m4x.org |
7 | 7 | Maintainer: Raphaël Barrois |
8 | 8 | Maintainer-email: raphael.barrois+django-ldapdb@polytechnique.org |
40 | 40 | * Full admin support and browsing |
41 | 41 | |
42 | 42 | |
43 | ``django-ldapdb`` supports Django versions 1.11 / 2.1 / 2.2, and Python 2.7 / 3.4 / 3.5 / 3.6 / 3.7, | |
44 | as far as the Django and Python versions are compatible. | |
43 | ``django-ldapdb`` supports every upstream-supported Django version, based on | |
44 | the `Django support policy <https://www.djangoproject.com/download/#supported-versions>`_. | |
45 | ||
46 | For the current version, the following versions are supported: | |
47 | ||
48 | - Django 2.2 (LTS), under Python 3.6 - 3.8 (Python 3.5 has reached its end of life); | |
49 | - Django 3.0, under Python 3.6 - 3.8; | |
50 | - Django 3.1, under Python 3.6 - 3.8. | |
45 | 51 | |
46 | 52 | |
47 | 53 | Installing django-ldapdb |
63 | 69 | or install a pre-built version from https://www.lfd.uci.edu/~gohlke/pythonlibs/#python-ldap |
64 | 70 | (choose the ``.whl`` file matching your Python/Windows combination, and install it with ``pip install python-ldap-3...whl``). |
65 | 71 | |
66 | and then you can also install ``django-ldapdb`` with | |
72 | You may then install ``django-ldapdb`` with | |
67 | 73 | |
68 | 74 | ``pip install django-ldapdb`` |
69 | 75 | |
180 | 186 | the timeout will be used on each individual request; |
181 | 187 | the overall processing time might be much higher. |
182 | 188 | |
183 | Keywords: django,ldap,database | |
189 | ||
190 | Developing with a LDAP server | |
191 | ----------------------------- | |
192 | ||
193 | When developing against a LDAP server, having access to a development LDAP server often proves | |
194 | useful. | |
195 | ||
196 | django-ldapdb uses the `volatildap project <https://pypi.org/project/volatildap>`_ for this purpose: | |
197 | ||
198 | - A LDAP server is instantiated for each TestClass; | |
199 | - Its content is reset at the start of each test function; | |
200 | - It can be customized to embark any schemas required by the application; | |
201 | - Starting with volatildap 1.4.0, the volatildap server can be controlled remotely, avoiding the need | |
202 | to install a LDAP server on the host. | |
203 | ||
204 | Applications using django-ldapdb may use the following code snippet when setting up their tests: | |
205 | ||
206 | .. code-block:: python | |
207 | ||
208 | # This snippet is released in the Public Domain | |
209 | ||
210 | from django.conf import settings | |
211 | from django.test import TestCase | |
212 | ||
213 | import volatildap | |
214 | ||
215 | class LdapEnabledTestCase(TestCase): | |
216 | @classmethod | |
217 | def setUpClass(cls): | |
218 | super().setUpClass() | |
219 | cls.ldap = volatildap.LdapServer( | |
220 | # Load some initial data | |
221 | initial={'ou=people': { | |
222 | 'ou': ['people'], | |
223 | 'objectClass': ['organizationalUnit'], | |
224 | }}, | |
225 | # Enable more LDAP schemas | |
226 | schemas=['core.schema', 'cosine.schema', 'inetorgperson.schema', 'nis.schema'], | |
227 | ) | |
228 | # The volatildap server uses specific defaults, and listens on an arbitrary port. | |
229 | # Copy the server-side values to Django settings | |
230 | settings.DATABASES['ldap']['USER'] = cls.ldap.rootdn | |
231 | settings.DATABASES['ldap']['PASSWORD'] = cls.ldap.rootpw | |
232 | settings.DATABASES['ldap']['NAME'] = cls.ldap.uri | |
233 | ||
234 | def setUp(self): | |
235 | super().setUp() | |
236 | # Starting an already-started volatildap server performs a data reset | |
237 | self.ldap.start() | |
238 | ||
239 | @classmethod | |
240 | def tearDownClass(cls): | |
241 | # Free up resources on teardown. | |
242 | cls.ldap.stop() | |
243 | super().tearDownClass() | |
244 | ||
245 | Keywords: django,ldap,database,ldapdb | |
184 | 246 | Platform: UNKNOWN |
185 | 247 | Classifier: Development Status :: 5 - Production/Stable |
186 | 248 | Classifier: Environment :: Web Environment |
187 | Classifier: Programming Language :: Python | |
188 | Classifier: Programming Language :: Python :: 2.7 | |
189 | Classifier: Programming Language :: Python :: 3.4 | |
190 | Classifier: Programming Language :: Python :: 3.5 | |
191 | Classifier: Programming Language :: Python :: 3.6 | |
192 | Classifier: Programming Language :: Python :: 3.7 | |
193 | Classifier: Framework :: Django :: 1.11 | |
194 | Classifier: Framework :: Django :: 2.0 | |
195 | Classifier: Framework :: Django :: 2.1 | |
249 | Classifier: Framework :: Django :: 2.2 | |
250 | Classifier: Framework :: Django :: 3.0 | |
251 | Classifier: Framework :: Django :: 3.1 | |
196 | 252 | Classifier: Intended Audience :: Developers |
197 | 253 | Classifier: Intended Audience :: System Administrators |
198 | 254 | Classifier: License :: OSI Approved :: BSD License |
255 | Classifier: Programming Language :: Python | |
256 | Classifier: Programming Language :: Python :: 3.6 | |
257 | Classifier: Programming Language :: Python :: 3.7 | |
258 | Classifier: Programming Language :: Python :: 3.8 | |
199 | 259 | Classifier: Topic :: Internet :: WWW/HTTP |
200 | 260 | Classifier: Topic :: System :: Systems Administration :: Authentication/Directory :: LDAP |
201 | 261 | Classifier: Topic :: Software Development :: Libraries :: Python Modules |
262 | Requires-Python: >=3.6 | |
263 | Provides-Extra: dev |
30 | 30 | * Full admin support and browsing |
31 | 31 | |
32 | 32 | |
33 | ``django-ldapdb`` supports Django versions 1.11 / 2.1 / 2.2, and Python 2.7 / 3.4 / 3.5 / 3.6 / 3.7, | |
34 | as far as the Django and Python versions are compatible. | |
33 | ``django-ldapdb`` supports every upstream-supported Django version, based on | |
34 | the `Django support policy <https://www.djangoproject.com/download/#supported-versions>`_. | |
35 | ||
36 | For the current version, the following versions are supported: | |
37 | ||
38 | - Django 2.2 (LTS), under Python 3.6 - 3.8 (Python 3.5 has reached its end of life); | |
39 | - Django 3.0, under Python 3.6 - 3.8; | |
40 | - Django 3.1, under Python 3.6 - 3.8. | |
35 | 41 | |
36 | 42 | |
37 | 43 | Installing django-ldapdb |
53 | 59 | or install a pre-built version from https://www.lfd.uci.edu/~gohlke/pythonlibs/#python-ldap |
54 | 60 | (choose the ``.whl`` file matching your Python/Windows combination, and install it with ``pip install python-ldap-3...whl``). |
55 | 61 | |
56 | and then you can also install ``django-ldapdb`` with | |
62 | You may then install ``django-ldapdb`` with | |
57 | 63 | |
58 | 64 | ``pip install django-ldapdb`` |
59 | 65 | |
169 | 175 | queries (for instance a paginated search yielding thousands of entries), |
170 | 176 | the timeout will be used on each individual request; |
171 | 177 | the overall processing time might be much higher. |
178 | ||
179 | ||
180 | Developing with a LDAP server | |
181 | ----------------------------- | |
182 | ||
183 | When developing against a LDAP server, having access to a development LDAP server often proves | |
184 | useful. | |
185 | ||
186 | django-ldapdb uses the `volatildap project <https://pypi.org/project/volatildap>`_ for this purpose: | |
187 | ||
188 | - A LDAP server is instantiated for each TestClass; | |
189 | - Its content is reset at the start of each test function; | |
190 | - It can be customized to embark any schemas required by the application; | |
191 | - Starting with volatildap 1.4.0, the volatildap server can be controlled remotely, avoiding the need | |
192 | to install a LDAP server on the host. | |
193 | ||
194 | Applications using django-ldapdb may use the following code snippet when setting up their tests: | |
195 | ||
196 | .. code-block:: python | |
197 | ||
198 | # This snippet is released in the Public Domain | |
199 | ||
200 | from django.conf import settings | |
201 | from django.test import TestCase | |
202 | ||
203 | import volatildap | |
204 | ||
205 | class LdapEnabledTestCase(TestCase): | |
206 | @classmethod | |
207 | def setUpClass(cls): | |
208 | super().setUpClass() | |
209 | cls.ldap = volatildap.LdapServer( | |
210 | # Load some initial data | |
211 | initial={'ou=people': { | |
212 | 'ou': ['people'], | |
213 | 'objectClass': ['organizationalUnit'], | |
214 | }}, | |
215 | # Enable more LDAP schemas | |
216 | schemas=['core.schema', 'cosine.schema', 'inetorgperson.schema', 'nis.schema'], | |
217 | ) | |
218 | # The volatildap server uses specific defaults, and listens on an arbitrary port. | |
219 | # Copy the server-side values to Django settings | |
220 | settings.DATABASES['ldap']['USER'] = cls.ldap.rootdn | |
221 | settings.DATABASES['ldap']['PASSWORD'] = cls.ldap.rootpw | |
222 | settings.DATABASES['ldap']['NAME'] = cls.ldap.uri | |
223 | ||
224 | def setUp(self): | |
225 | super().setUp() | |
226 | # Starting an already-started volatildap server performs a data reset | |
227 | self.ldap.start() | |
228 | ||
229 | @classmethod | |
230 | def tearDownClass(cls): | |
231 | # Free up resources on teardown. | |
232 | cls.ldap.stop() | |
233 | super().tearDownClass() |
0 | Metadata-Version: 1.2 | |
0 | Metadata-Version: 2.1 | |
1 | 1 | Name: django-ldapdb |
2 | Version: 1.4.0 | |
3 | Summary: An LDAP database backend for Django | |
2 | Version: 1.5.1 | |
3 | Summary: A LDAP database backend for Django | |
4 | 4 | Home-page: https://github.com/django-ldapdb/django-ldapdb |
5 | Author: Jeremy Laine | |
5 | Author: Jeremy Lainé | |
6 | 6 | Author-email: jeremy.laine@m4x.org |
7 | 7 | Maintainer: Raphaël Barrois |
8 | 8 | Maintainer-email: raphael.barrois+django-ldapdb@polytechnique.org |
40 | 40 | * Full admin support and browsing |
41 | 41 | |
42 | 42 | |
43 | ``django-ldapdb`` supports Django versions 1.11 / 2.1 / 2.2, and Python 2.7 / 3.4 / 3.5 / 3.6 / 3.7, | |
44 | as far as the Django and Python versions are compatible. | |
43 | ``django-ldapdb`` supports every upstream-supported Django version, based on | |
44 | the `Django support policy <https://www.djangoproject.com/download/#supported-versions>`_. | |
45 | ||
46 | For the current version, the following versions are supported: | |
47 | ||
48 | - Django 2.2 (LTS), under Python 3.6 - 3.8 (Python 3.5 has reached its end of life); | |
49 | - Django 3.0, under Python 3.6 - 3.8; | |
50 | - Django 3.1, under Python 3.6 - 3.8. | |
45 | 51 | |
46 | 52 | |
47 | 53 | Installing django-ldapdb |
63 | 69 | or install a pre-built version from https://www.lfd.uci.edu/~gohlke/pythonlibs/#python-ldap |
64 | 70 | (choose the ``.whl`` file matching your Python/Windows combination, and install it with ``pip install python-ldap-3...whl``). |
65 | 71 | |
66 | and then you can also install ``django-ldapdb`` with | |
72 | You may then install ``django-ldapdb`` with | |
67 | 73 | |
68 | 74 | ``pip install django-ldapdb`` |
69 | 75 | |
180 | 186 | the timeout will be used on each individual request; |
181 | 187 | the overall processing time might be much higher. |
182 | 188 | |
183 | Keywords: django,ldap,database | |
189 | ||
190 | Developing with a LDAP server | |
191 | ----------------------------- | |
192 | ||
193 | When developing against a LDAP server, having access to a development LDAP server often proves | |
194 | useful. | |
195 | ||
196 | django-ldapdb uses the `volatildap project <https://pypi.org/project/volatildap>`_ for this purpose: | |
197 | ||
198 | - A LDAP server is instantiated for each TestClass; | |
199 | - Its content is reset at the start of each test function; | |
200 | - It can be customized to embark any schemas required by the application; | |
201 | - Starting with volatildap 1.4.0, the volatildap server can be controlled remotely, avoiding the need | |
202 | to install a LDAP server on the host. | |
203 | ||
204 | Applications using django-ldapdb may use the following code snippet when setting up their tests: | |
205 | ||
206 | .. code-block:: python | |
207 | ||
208 | # This snippet is released in the Public Domain | |
209 | ||
210 | from django.conf import settings | |
211 | from django.test import TestCase | |
212 | ||
213 | import volatildap | |
214 | ||
215 | class LdapEnabledTestCase(TestCase): | |
216 | @classmethod | |
217 | def setUpClass(cls): | |
218 | super().setUpClass() | |
219 | cls.ldap = volatildap.LdapServer( | |
220 | # Load some initial data | |
221 | initial={'ou=people': { | |
222 | 'ou': ['people'], | |
223 | 'objectClass': ['organizationalUnit'], | |
224 | }}, | |
225 | # Enable more LDAP schemas | |
226 | schemas=['core.schema', 'cosine.schema', 'inetorgperson.schema', 'nis.schema'], | |
227 | ) | |
228 | # The volatildap server uses specific defaults, and listens on an arbitrary port. | |
229 | # Copy the server-side values to Django settings | |
230 | settings.DATABASES['ldap']['USER'] = cls.ldap.rootdn | |
231 | settings.DATABASES['ldap']['PASSWORD'] = cls.ldap.rootpw | |
232 | settings.DATABASES['ldap']['NAME'] = cls.ldap.uri | |
233 | ||
234 | def setUp(self): | |
235 | super().setUp() | |
236 | # Starting an already-started volatildap server performs a data reset | |
237 | self.ldap.start() | |
238 | ||
239 | @classmethod | |
240 | def tearDownClass(cls): | |
241 | # Free up resources on teardown. | |
242 | cls.ldap.stop() | |
243 | super().tearDownClass() | |
244 | ||
245 | Keywords: django,ldap,database,ldapdb | |
184 | 246 | Platform: UNKNOWN |
185 | 247 | Classifier: Development Status :: 5 - Production/Stable |
186 | 248 | Classifier: Environment :: Web Environment |
187 | Classifier: Programming Language :: Python | |
188 | Classifier: Programming Language :: Python :: 2.7 | |
189 | Classifier: Programming Language :: Python :: 3.4 | |
190 | Classifier: Programming Language :: Python :: 3.5 | |
191 | Classifier: Programming Language :: Python :: 3.6 | |
192 | Classifier: Programming Language :: Python :: 3.7 | |
193 | Classifier: Framework :: Django :: 1.11 | |
194 | Classifier: Framework :: Django :: 2.0 | |
195 | Classifier: Framework :: Django :: 2.1 | |
249 | Classifier: Framework :: Django :: 2.2 | |
250 | Classifier: Framework :: Django :: 3.0 | |
251 | Classifier: Framework :: Django :: 3.1 | |
196 | 252 | Classifier: Intended Audience :: Developers |
197 | 253 | Classifier: Intended Audience :: System Administrators |
198 | 254 | Classifier: License :: OSI Approved :: BSD License |
255 | Classifier: Programming Language :: Python | |
256 | Classifier: Programming Language :: Python :: 3.6 | |
257 | Classifier: Programming Language :: Python :: 3.7 | |
258 | Classifier: Programming Language :: Python :: 3.8 | |
199 | 259 | Classifier: Topic :: Internet :: WWW/HTTP |
200 | 260 | Classifier: Topic :: System :: Systems Administration :: Authentication/Directory :: LDAP |
201 | 261 | Classifier: Topic :: Software Development :: Libraries :: Python Modules |
262 | Requires-Python: >=3.6 | |
263 | Provides-Extra: dev |
0 | .flake8 | |
1 | 0 | AUTHORS |
2 | 1 | CODE_OF_CONDUCT.md |
3 | 2 | CONTRIBUTING.rst |
7 | 6 | Makefile |
8 | 7 | README.rst |
9 | 8 | manage_dev.py |
10 | requirements_dev.txt | |
11 | requirements_test.txt | |
12 | 9 | setup.cfg |
13 | 10 | setup.py |
14 | 11 | tox.ini |
15 | 12 | django_ldapdb.egg-info/PKG-INFO |
16 | 13 | django_ldapdb.egg-info/SOURCES.txt |
17 | 14 | django_ldapdb.egg-info/dependency_links.txt |
15 | django_ldapdb.egg-info/not-zip-safe | |
18 | 16 | django_ldapdb.egg-info/requires.txt |
19 | 17 | django_ldapdb.egg-info/top_level.txt |
20 | django_ldapdb.egg-info/zip-safe | |
21 | 18 | examples/__init__.py |
22 | 19 | examples/admin.py |
23 | 20 | examples/models.py |
0 | Django>=1.11 | |
0 | Django>=2.2 | |
1 | 1 | python-ldap>=3.0 |
2 | ||
3 | [dev] | |
4 | check-manifest | |
5 | flake8 | |
6 | isort>=5.0.0 | |
7 | tox | |
8 | factory_boy | |
9 | volatildap>=1.1.0 | |
10 | wheel | |
11 | zest.releaser[recommended] |
0 | 0 | # -*- coding: utf-8 -*- |
1 | 1 | # This software is distributed under the two-clause BSD license. |
2 | 2 | # Copyright (c) The django-ldapdb project |
3 | ||
4 | from __future__ import unicode_literals | |
5 | 3 | |
6 | 4 | import ldapdb.models |
7 | 5 | from ldapdb.models import fields |
14 | 12 | # LDAP meta-data |
15 | 13 | base_dn = "ou=people,dc=example,dc=org" |
16 | 14 | object_classes = ['posixAccount', 'shadowAccount', 'inetOrgPerson'] |
17 | last_modified = fields.DateTimeField(db_column='modifyTimestamp') | |
15 | last_modified = fields.DateTimeField(db_column='modifyTimestamp', editable=False) | |
18 | 16 | |
19 | 17 | # inetOrgPerson |
20 | 18 | first_name = fields.CharField(db_column='givenName', verbose_name="Prime name") |
0 | 0 | # -*- coding: utf-8 -*- |
1 | 1 | # This software is distributed under the two-clause BSD license. |
2 | 2 | # Copyright (c) The django-ldapdb project |
3 | ||
4 | from __future__ import unicode_literals | |
5 | 3 | |
6 | 4 | import ldap |
7 | 5 | |
92 | 90 | 'django.template.context_processors.debug', |
93 | 91 | 'django.template.context_processors.i18n', |
94 | 92 | 'django.template.context_processors.media', |
93 | 'django.template.context_processors.request', | |
95 | 94 | 'django.template.context_processors.static', |
96 | 95 | 'django.template.context_processors.tz', |
97 | 96 | 'django.contrib.messages.context_processors.messages', |
0 | 0 | # -*- coding: utf-8 -*- |
1 | 1 | # This software is distributed under the two-clause BSD license. |
2 | 2 | # Copyright (c) The django-ldapdb project |
3 | ||
4 | from __future__ import unicode_literals | |
5 | 3 | |
6 | 4 | import time |
7 | 5 | |
99 | 97 | |
100 | 98 | @classmethod |
101 | 99 | def setUpClass(cls): |
102 | super(BaseTestCase, cls).setUpClass() | |
100 | super().setUpClass() | |
103 | 101 | cls.ldap_server = volatildap.LdapServer( |
104 | 102 | initial_data=cls.directory, |
105 | 103 | schemas=['core.schema', 'cosine.schema', 'inetorgperson.schema', 'nis.schema'], |
111 | 109 | @classmethod |
112 | 110 | def tearDownClass(cls): |
113 | 111 | cls.ldap_server.stop() |
114 | super(BaseTestCase, cls).tearDownClass() | |
112 | super().tearDownClass() | |
115 | 113 | |
116 | 114 | def setUp(self): |
117 | super(BaseTestCase, self).setUp() | |
115 | super().setUp() | |
118 | 116 | self.ldap_server.start() |
119 | 117 | |
120 | 118 | |
690 | 688 | directory = dict([groups, people, foogroup, contacts]) |
691 | 689 | |
692 | 690 | def setUp(self): |
693 | super(ScopedTestCase, self).setUp() | |
691 | super().setUp() | |
694 | 692 | self.scoped_model = LdapGroup.scoped("ou=contacts,%s" % |
695 | 693 | LdapGroup.base_dn) |
696 | 694 | |
808 | 806 | directory = dict([groups, people, foouser, foogroup, bargroup]) |
809 | 807 | |
810 | 808 | def setUp(self): |
811 | super(AdminTestCase, self).setUp() | |
809 | super().setUp() | |
812 | 810 | self._user = UserFactory( |
813 | 811 | username='test_user', |
814 | 812 | cleartext_password='password', |
2 | 2 | # Copyright (c) The django-ldapdb project |
3 | 3 | |
4 | 4 | |
5 | from django.conf.urls import include, url | |
6 | 5 | from django.contrib import admin |
6 | from django.urls import include, path | |
7 | 7 | |
8 | 8 | admin.autodiscover() |
9 | 9 | |
10 | 10 | urlpatterns = [ |
11 | url(r'^admin/doc/', include('django.contrib.admindocs.urls')), | |
12 | url(r'^admin/', admin.site.urls), | |
11 | path('admin/doc/', include('django.contrib.admindocs.urls')), | |
12 | path('admin/', admin.site.urls), | |
13 | 13 | ] |
2 | 2 | # Copyright (c) The django-ldapdb project |
3 | 3 | |
4 | 4 | |
5 | import sys | |
6 | ||
7 | 5 | import ldap.filter |
8 | 6 | from django.conf import settings |
9 | 7 | |
8 | from .version import __version__ # noqa | |
9 | ||
10 | 10 | |
11 | 11 | def escape_ldap_filter(value): |
12 | if sys.version_info[0] < 3: | |
13 | text_value = unicode(value) # noqa: F821 | |
14 | else: | |
15 | text_value = str(value) | |
16 | return ldap.filter.escape_filter_chars(text_value) | |
12 | return ldap.filter.escape_filter_chars(str(value)) | |
17 | 13 | |
18 | 14 | |
19 | 15 | # Legacy single database support |
20 | 16 | if hasattr(settings, 'LDAPDB_SERVER_URI'): |
21 | 17 | from django import db |
18 | ||
22 | 19 | from ldapdb.router import Router |
23 | 20 | |
24 | 21 | # Add the LDAP backend |
1 | 1 | # This software is distributed under the two-clause BSD license. |
2 | 2 | # Copyright (c) The django-ldapdb project |
3 | 3 | |
4 | from __future__ import unicode_literals | |
5 | ||
4 | import django | |
6 | 5 | import ldap |
7 | 6 | import ldap.controls |
8 | 7 | from django.db.backends.base.base import BaseDatabaseWrapper |
72 | 71 | def no_limit_value(self): |
73 | 72 | return -1 |
74 | 73 | |
75 | def sql_flush(self, style, tables, sequences, allow_cascade=False): | |
74 | def sql_flush(self, style, tables, *, allow_cascade=False, reset_sequences=False): | |
76 | 75 | return [] |
76 | ||
77 | if django.VERSION < (3, 1): | |
78 | # Backwards compatibility | |
79 | def sql_flush(self, style, tables, sequences, allow_cascade=False): # noqa | |
80 | return [] | |
77 | 81 | |
78 | 82 | |
79 | 83 | class DatabaseValidation(BaseDatabaseValidation): |
214 | 218 | } |
215 | 219 | |
216 | 220 | def __init__(self, *args, **kwargs): |
217 | super(DatabaseWrapper, self).__init__(*args, **kwargs) | |
221 | super().__init__(*args, **kwargs) | |
218 | 222 | |
219 | 223 | # Charset used for LDAP text *values* |
220 | 224 | self.charset = "utf-8" |
253 | 257 | } |
254 | 258 | |
255 | 259 | def ensure_connection(self): |
256 | super(DatabaseWrapper, self).ensure_connection() | |
260 | super().ensure_connection() | |
257 | 261 | |
258 | 262 | # Do a test bind, which will revive the connection if interrupted, or reconnect |
259 | 263 | conn_params = self.get_connection_params() |
1 | 1 | # This software is distributed under the two-clause BSD license. |
2 | 2 | # Copyright (c) The django-ldapdb project |
3 | 3 | |
4 | from __future__ import unicode_literals | |
5 | ||
6 | 4 | import collections |
7 | 5 | import re |
8 | import sys | |
9 | 6 | |
10 | 7 | import ldap |
11 | 8 | from django.db.models import aggregates |
15 | 12 | |
16 | 13 | from ldapdb import escape_ldap_filter |
17 | 14 | from ldapdb.models.fields import ListField |
18 | ||
19 | if sys.version_info[0] < 3: | |
20 | integer_types = (int, long) # noqa: F821 | |
21 | else: | |
22 | integer_types = (int,) | |
23 | ||
24 | 15 | |
25 | 16 | _ORDER_BY_LIMIT_OFFSET_RE = re.compile( |
26 | 17 | r'(?:\bORDER BY\b\s+(.+?))?\s*(?:\bLIMIT\b\s+(-?\d+))?\s*(?:\bOFFSET\b\s+(\d+))?$') |
113 | 104 | """Parse a WhereNode to a LDAP filter string.""" |
114 | 105 | if isinstance(node, WhereNode): |
115 | 106 | return where_node_as_ldap(node, self, self.connection) |
116 | return super(SQLCompiler, self).compile(node, *args, **kwargs) | |
107 | return super().compile(node, *args, **kwargs) | |
117 | 108 | |
118 | 109 | def execute_sql(self, result_type=compiler.SINGLE, chunked_fetch=False, |
119 | 110 | chunk_size=GET_ITERATOR_CHUNK_SIZE): |
312 | 303 | class SQLAggregateCompiler(compiler.SQLAggregateCompiler, SQLCompiler): |
313 | 304 | def execute_sql(self, result_type=compiler.SINGLE): |
314 | 305 | # Return only number values through the aggregate compiler |
315 | output = super(SQLAggregateCompiler, self).execute_sql(result_type) | |
316 | if sys.version_info < (3,): | |
317 | return filter(lambda a: isinstance(a, int), output) | |
318 | return filter(lambda a: isinstance(a, integer_types), output) | |
306 | output = super().execute_sql(result_type) | |
307 | return filter(lambda a: isinstance(a, int), output) |
0 | 0 | # -*- coding: utf-8 -*- |
1 | 1 | # This software is distributed under the two-clause BSD license. |
2 | 2 | # Copyright (c) The django-ldapdb project |
3 | ||
4 | from __future__ import unicode_literals | |
5 | 3 | |
6 | 4 | import logging |
7 | 5 | |
27 | 25 | object_classes = ['top'] |
28 | 26 | |
29 | 27 | def __init__(self, *args, **kwargs): |
30 | super(Model, self).__init__(*args, **kwargs) | |
28 | super().__init__(*args, **kwargs) | |
31 | 29 | self._saved_dn = self.dn |
32 | 30 | if self.dn: |
33 | 31 | self.base_dn = self.dn.split(',', 1)[1] |
0 | 0 | # -*- coding: utf-8 -*- |
1 | 1 | # This software is distributed under the two-clause BSD license. |
2 | 2 | # Copyright (c) The django-ldapdb project |
3 | ||
4 | from __future__ import unicode_literals | |
5 | 3 | |
6 | 4 | import datetime |
7 | 5 | import re |
145 | 143 | def __init__(self, *args, **kwargs): |
146 | 144 | defaults = {'max_length': 200} |
147 | 145 | defaults.update(kwargs) |
148 | super(CharField, self).__init__(*args, **defaults) | |
146 | super().__init__(*args, **defaults) | |
149 | 147 | |
150 | 148 | def from_ldap(self, value, connection): |
151 | 149 | if len(value) == 0: |
183 | 181 | return int(value[0]) |
184 | 182 | |
185 | 183 | def get_prep_value(self, value): |
186 | value = super(IntegerField, self).get_prep_value(value) | |
184 | value = super().get_prep_value(value) | |
187 | 185 | return str(value) |
188 | 186 | |
189 | 187 | |
201 | 199 | return float(value[0]) |
202 | 200 | |
203 | 201 | def get_prep_value(self, value): |
204 | value = super(FloatField, self).get_prep_value(value) | |
202 | value = super().get_prep_value(value) | |
205 | 203 | return str(value) |
206 | 204 | |
207 | 205 | |
219 | 217 | return value[0].upper() == b'TRUE' |
220 | 218 | |
221 | 219 | def get_prep_value(self, value): |
222 | value = super(BooleanField, self).get_prep_value(value) | |
220 | value = super().get_prep_value(value) | |
223 | 221 | return 'TRUE' if value else 'FALSE' |
224 | 222 | |
225 | 223 | |
266 | 264 | self._date_format = kwargs.pop('format') |
267 | 265 | else: |
268 | 266 | self._date_format = '%Y-%m-%d' |
269 | super(DateField, self).__init__(*args, **kwargs) | |
267 | super().__init__(*args, **kwargs) | |
270 | 268 | |
271 | 269 | def from_ldap(self, value, connection): |
272 | 270 | if len(value) == 0: |
276 | 274 | self._date_format).date() |
277 | 275 | |
278 | 276 | def get_prep_value(self, value): |
279 | value = super(DateField, self).get_prep_value(value) | |
277 | value = super().get_prep_value(value) | |
280 | 278 | if not isinstance(value, datetime.date) \ |
281 | 279 | and not isinstance(value, datetime.datetime): |
282 | 280 | raise ValueError( |
349 | 347 | return datetime_from_ldap(value[0].decode(connection.charset)) |
350 | 348 | |
351 | 349 | def get_prep_value(self, value): |
352 | value = super(DateTimeField, self).get_prep_value(value) | |
350 | value = super().get_prep_value(value) | |
353 | 351 | if not isinstance(value, datetime.date) \ |
354 | 352 | and not isinstance(value, datetime.datetime): |
355 | 353 | raise ValueError( |
1 | 1 | # This software is distributed under the two-clause BSD license. |
2 | 2 | # Copyright (c) The django-ldapdb project |
3 | 3 | |
4 | ||
5 | from __future__ import unicode_literals | |
6 | 4 | |
7 | 5 | import datetime |
8 | 6 |
1 | 1 | # This software is distributed under the two-clause BSD license. |
2 | 2 | # Copyright (c) The django-ldapdb project |
3 | 3 | |
4 | from __future__ import unicode_literals | |
4 | import sys | |
5 | 5 | |
6 | __version__ = '1.4.0' | |
6 | if sys.version_info < (3, 8): | |
7 | import pkg_resources | |
8 | ||
9 | __version__ = pkg_resources.get_distribution('django-ldapdb').version | |
10 | ||
11 | else: | |
12 | import importlib.metadata | |
13 | ||
14 | __version__ = importlib.metadata.version('django-ldapdb') | |
7 | 15 | |
8 | 16 | VERSION = __version__ |
0 | # Requirements for executing tests | |
1 | check-manifest | |
2 | flake8 | |
3 | factory_boy | |
4 | isort | |
5 | volatildap>=1.1.0 |
0 | [metadata] | |
1 | name = django-ldapdb | |
2 | version = 1.5.1 | |
3 | description = A LDAP database backend for Django | |
4 | long_description = file: README.rst | |
5 | keywords = django, ldap, database, ldapdb | |
6 | url = https://github.com/django-ldapdb/django-ldapdb | |
7 | author = Jeremy Lainé | |
8 | author_email = jeremy.laine@m4x.org | |
9 | maintainer = Raphaël Barrois | |
10 | maintainer_email = raphael.barrois+django-ldapdb@polytechnique.org | |
11 | license = BSD | |
12 | classifiers = | |
13 | Development Status :: 5 - Production/Stable | |
14 | Environment :: Web Environment | |
15 | Framework :: Django :: 2.2 | |
16 | Framework :: Django :: 3.0 | |
17 | Framework :: Django :: 3.1 | |
18 | Intended Audience :: Developers | |
19 | Intended Audience :: System Administrators | |
20 | License :: OSI Approved :: BSD License | |
21 | Programming Language :: Python | |
22 | Programming Language :: Python :: 3.6 | |
23 | Programming Language :: Python :: 3.7 | |
24 | Programming Language :: Python :: 3.8 | |
25 | Topic :: Internet :: WWW/HTTP | |
26 | Topic :: System :: Systems Administration :: Authentication/Directory :: LDAP | |
27 | Topic :: Software Development :: Libraries :: Python Modules | |
28 | ||
29 | [options] | |
30 | zip_safe = false | |
31 | packages = find: | |
32 | include_package_data = true | |
33 | python_requires = >=3.6 | |
34 | install_requires = | |
35 | Django>=2.2 | |
36 | python-ldap>=3.0 | |
37 | setup_requires = setuptools | |
38 | ||
39 | [options.packages.find] | |
40 | include = | |
41 | ldapdb | |
42 | ||
43 | [options.extras_require] | |
44 | dev = | |
45 | check-manifest | |
46 | flake8 | |
47 | isort>=5.0.0 | |
48 | tox | |
49 | factory_boy | |
50 | volatildap>=1.1.0 | |
51 | wheel | |
52 | zest.releaser[recommended] | |
53 | ||
0 | 54 | [bdist_wheel] |
1 | 55 | universal = true |
2 | 56 | |
3 | 57 | [zest.releaser] |
4 | 58 | version-levels = 3 |
5 | python-file-with-version = ldapdb/version.py | |
6 | 59 | |
7 | 60 | [distutils] |
8 | 61 | index-servers = pypi |
62 | ||
63 | [flake8] | |
64 | max-line-length = 120 | |
65 | ignore = W503 | |
9 | 66 | |
10 | 67 | [egg_info] |
11 | 68 | tag_build = |
2 | 2 | # This software is distributed under the two-clause BSD license. |
3 | 3 | # Copyright (c) The django-ldapdb project |
4 | 4 | |
5 | from __future__ import unicode_literals | |
5 | from setuptools import setup | |
6 | 6 | |
7 | import codecs | |
8 | import os | |
9 | import re | |
10 | ||
11 | from setuptools import find_packages, setup | |
12 | ||
13 | root_dir = os.path.abspath(os.path.dirname(__file__)) | |
14 | ||
15 | ||
16 | def get_version(package_name): | |
17 | version_re = re.compile(r"^__version__ = [\"']([\w_.-]+)[\"']$") | |
18 | package_components = package_name.split('.') | |
19 | init_path = os.path.join(root_dir, *(package_components + ['version.py'])) | |
20 | with codecs.open(init_path, 'r', 'utf-8') as f: | |
21 | for line in f: | |
22 | match = version_re.match(line[:-1]) | |
23 | if match: | |
24 | return match.groups()[0] | |
25 | return '0.1.0' | |
26 | ||
27 | ||
28 | PACKAGE = 'django-ldapdb' | |
29 | PYPACKAGE = 'ldapdb' | |
30 | ||
31 | ||
32 | setup( | |
33 | name=PACKAGE, | |
34 | version=get_version(PYPACKAGE), | |
35 | description="An LDAP database backend for Django", | |
36 | long_description=''.join(codecs.open('README.rst', 'r', 'utf-8').readlines()), | |
37 | author="Jeremy Laine", | |
38 | author_email="jeremy.laine@m4x.org", | |
39 | maintainer="Raphaël Barrois", | |
40 | maintainer_email="raphael.barrois+%s@polytechnique.org" % PACKAGE, | |
41 | license="BSD", | |
42 | zip_safe=True, | |
43 | keywords=['django', 'ldap', 'database'], | |
44 | url="https://github.com/{pn}/{pn}".format(pn=PACKAGE), | |
45 | packages=find_packages(exclude=['tests*', 'examples*']), | |
46 | install_requires=[ | |
47 | 'Django>=1.11', | |
48 | 'python-ldap>=3.0', | |
49 | ], | |
50 | setup_requires=[ | |
51 | 'setuptools>=0.8', | |
52 | ], | |
53 | classifiers=[ | |
54 | "Development Status :: 5 - Production/Stable", | |
55 | "Environment :: Web Environment", | |
56 | "Programming Language :: Python", | |
57 | "Programming Language :: Python :: 2.7", | |
58 | "Programming Language :: Python :: 3.4", | |
59 | "Programming Language :: Python :: 3.5", | |
60 | "Programming Language :: Python :: 3.6", | |
61 | "Programming Language :: Python :: 3.7", | |
62 | "Framework :: Django :: 1.11", | |
63 | "Framework :: Django :: 2.0", | |
64 | "Framework :: Django :: 2.1", | |
65 | "Intended Audience :: Developers", | |
66 | "Intended Audience :: System Administrators", | |
67 | "License :: OSI Approved :: BSD License", | |
68 | "Topic :: Internet :: WWW/HTTP", | |
69 | "Topic :: System :: Systems Administration :: Authentication/Directory :: LDAP", | |
70 | "Topic :: Software Development :: Libraries :: Python Modules", | |
71 | ], | |
72 | test_suite = 'manage_dev.run_tests', | |
73 | ) | |
7 | setup() |
0 | 0 | [tox] |
1 | envlist = py{27,34,35,36,37}-django111, py{35,36,37}-django21, py{35,36,37}-django22, lint | |
1 | envlist = py{36,37,38}-django{22,30,31}, lint | |
2 | 2 | |
3 | 3 | [testenv] |
4 | extras = dev | |
4 | 5 | deps = |
5 | -rrequirements_test.txt | |
6 | django111: Django>=1.11,<1.12 | |
7 | django21: Django>=2.1,<2.2 | |
8 | 6 | django22: Django>=2.2,<2.3 |
7 | django30: Django>=3.0,<3.1 | |
8 | django31: Django>=3.1,<3.2 | |
9 | 9 | |
10 | 10 | whitelist_externals = make |
11 | 11 | commands = make test |
12 | 12 | |
13 | 13 | [testenv:lint] |
14 | deps = | |
15 | -rrequirements_test.txt | |
14 | extras = dev | |
16 | 15 | whitelist_externals = make |
17 | 16 | commands = make lint |