From fe23ab46da33828f92c6aff3ce73a7bd1c806ca7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Freitag?= Date: Fri, 21 Jan 2022 16:00:48 +0100 Subject: [PATCH 01/11] Move LDAPSetting to the config module Settings are configuration, it makes more sense for it to live there. --- django_auth_ldap/backend.py | 61 +++++-------------------------------- django_auth_ldap/config.py | 54 ++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+), 54 deletions(-) diff --git a/django_auth_ldap/backend.py b/django_auth_ldap/backend.py index e8f12ea4..529ec6dc 100644 --- a/django_auth_ldap/backend.py +++ b/django_auth_ldap/backend.py @@ -55,7 +55,13 @@ from django.core.cache import cache from django.core.exceptions import ImproperlyConfigured, ObjectDoesNotExist -from .config import ConfigurationWarning, LDAPGroupQuery, LDAPSearch, _LDAPConfig +from .config import ( + ConfigurationWarning, + LDAPGroupQuery, + LDAPSearch, + LDAPSettings, + _LDAPConfig, +) logger = _LDAPConfig.get_logger() @@ -968,59 +974,6 @@ def _cache_key(self, attr_name): ) -class LDAPSettings: - """ - This is a simple class to take the place of the global settings object. An - instance will contain all of our settings as attributes, with default values - if they are not specified by the configuration. - """ - - _prefix = "AUTH_LDAP_" - - defaults = { - "ALWAYS_UPDATE_USER": True, - "AUTHORIZE_ALL_USERS": False, - "BIND_AS_AUTHENTICATING_USER": False, - "BIND_DN": "", - "BIND_PASSWORD": "", - "CONNECTION_OPTIONS": {}, - "DENY_GROUP": None, - "FIND_GROUP_PERMS": False, - "CACHE_TIMEOUT": 0, - "GROUP_SEARCH": None, - "GROUP_TYPE": None, - "MIRROR_GROUPS": None, - "MIRROR_GROUPS_EXCEPT": None, - "PERMIT_EMPTY_PASSWORD": False, - "REQUIRE_GROUP": None, - "NO_NEW_USERS": False, - "SERVER_URI": "ldap://localhost", - "START_TLS": False, - "USER_QUERY_FIELD": None, - "USER_ATTRLIST": None, - "USER_ATTR_MAP": {}, - "USER_DN_TEMPLATE": None, - "USER_FLAGS_BY_GROUP": {}, - "USER_SEARCH": None, - } - - def __init__(self, prefix="AUTH_LDAP_", defaults={}): - """ - Loads our settings from django.conf.settings, applying defaults for any - that are omitted. - """ - self._prefix = prefix - - defaults = dict(self.defaults, **defaults) - - for name, default in defaults.items(): - value = getattr(django.conf.settings, prefix + name, default) - setattr(self, name, value) - - def _name(self, suffix): - return self._prefix + suffix - - def valid_cache_key(key): """ Sanitizes a cache key for memcached. diff --git a/django_auth_ldap/config.py b/django_auth_ldap/config.py index a1781bc4..13207512 100644 --- a/django_auth_ldap/config.py +++ b/django_auth_ldap/config.py @@ -34,6 +34,7 @@ import ldap import ldap.filter +from django.conf import settings from django.utils.tree import Node @@ -41,6 +42,59 @@ class ConfigurationWarning(UserWarning): pass +class LDAPSettings: + """ + This is a simple class to take the place of the global settings object. An + instance will contain all of our settings as attributes, with default values + if they are not specified by the configuration. + """ + + _prefix = "AUTH_LDAP_" + + defaults = { + "ALWAYS_UPDATE_USER": True, + "AUTHORIZE_ALL_USERS": False, + "BIND_AS_AUTHENTICATING_USER": False, + "BIND_DN": "", + "BIND_PASSWORD": "", + "CONNECTION_OPTIONS": {}, + "DENY_GROUP": None, + "FIND_GROUP_PERMS": False, + "CACHE_TIMEOUT": 0, + "GROUP_SEARCH": None, + "GROUP_TYPE": None, + "MIRROR_GROUPS": None, + "MIRROR_GROUPS_EXCEPT": None, + "PERMIT_EMPTY_PASSWORD": False, + "REQUIRE_GROUP": None, + "NO_NEW_USERS": False, + "SERVER_URI": "ldap://localhost", + "START_TLS": False, + "USER_QUERY_FIELD": None, + "USER_ATTRLIST": None, + "USER_ATTR_MAP": {}, + "USER_DN_TEMPLATE": None, + "USER_FLAGS_BY_GROUP": {}, + "USER_SEARCH": None, + } + + def __init__(self, prefix="AUTH_LDAP_", defaults={}): + """ + Loads our settings from django.conf.settings, applying defaults for any + that are omitted. + """ + self._prefix = prefix + + defaults = dict(self.defaults, **defaults) + + for name, default in defaults.items(): + value = getattr(settings, prefix + name, default) + setattr(self, name, value) + + def _name(self, suffix): + return self._prefix + suffix + + class _LDAPConfig: """ A private class that loads and caches some global objects. From 8c2eb6a4788f6825fa84934c5990b3d72759f2d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Freitag?= Date: Mon, 13 Jun 2022 14:09:10 +0200 Subject: [PATCH 02/11] Fix docs build for newer Sphinx The language configuration option must now be set, and will issue a warning when unset. https://www.sphinx-doc.org/en/master/changes.html#id15 --- docs/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/conf.py b/docs/conf.py index 30a6c446..598ef406 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -78,7 +78,7 @@ def chdir(directory): # # This is also used if you do content translation via gettext catalogs. # Usually you set "language" from the command line for these cases. -language = None +language = "en" # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. From 3f664c5cee1cceac632463d9ee0f90142a0f28ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Freitag?= Date: Mon, 13 Jun 2022 14:10:21 +0200 Subject: [PATCH 03/11] Fail packaging build on twine warning --- tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index 77df4f01..07947a9b 100644 --- a/tox.ini +++ b/tox.ini @@ -50,4 +50,4 @@ deps = skip_install = true commands = python -m build - twine check dist/* + twine check --strict dist/* From b701cc9aadb8c9a1072ee6a11360275c04518840 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Freitag?= Date: Tue, 16 Aug 2022 12:14:45 +0200 Subject: [PATCH 04/11] Add django40 to the tox envlist --- tox.ini | 1 + 1 file changed, 1 insertion(+) diff --git a/tox.ini b/tox.ini index 07947a9b..b5743d70 100644 --- a/tox.ini +++ b/tox.ini @@ -6,6 +6,7 @@ envlist = docs django22 django32 + django40 djangomain isolated_build = true From 55d2ebe6ba55f3fc8468b19bd3fafe60d64b5641 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Freitag?= Date: Tue, 16 Aug 2022 13:41:18 +0200 Subject: [PATCH 05/11] Drop support for Django 2.2 Removed mention of supported versions in the README, can use the PyPI metadata declared in setup.cfg. --- .github/workflows/test.yml | 8 +------- README.rst | 3 --- setup.cfg | 3 +-- tox.ini | 2 -- 4 files changed, 2 insertions(+), 14 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c3b61b5c..38946427 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -17,18 +17,12 @@ jobs: - 3.9 - '3.10' tox-environment: - - django22 - django32 - django40 + - djangomain include: - - python-version: 3.7 - tox-environment: django22 - python-version: 3.7 tox-environment: django32 - - python-version: 3.9 - tox-environment: djangomain - - python-version: '3.10' - tox-environment: djangomain env: TOXENV: ${{ matrix.tox-environment }} diff --git a/README.rst b/README.rst index 8162b490..d96ad14f 100644 --- a/README.rst +++ b/README.rst @@ -24,9 +24,6 @@ groups, and permissions. * Repository: https://github.com/django-auth-ldap/django-auth-ldap * License: BSD 2-Clause -This version is supported on Python 3.7+; and Django 2.2+. It requires -`python-ldap`_ >= 3.1. - .. _`python-ldap`: https://pypi.org/project/python-ldap/ diff --git a/setup.cfg b/setup.cfg index 63e5f7dc..aad576ab 100644 --- a/setup.cfg +++ b/setup.cfg @@ -11,7 +11,6 @@ classifiers = Development Status :: 5 - Production/Stable Environment :: Web Environment Framework :: Django - Framework :: Django :: 2.2 Framework :: Django :: 3.2 Framework :: Django :: 4.0 Intended Audience :: Developers @@ -36,7 +35,7 @@ project_urls = python_requires = >=3.7 packages = django_auth_ldap install_requires = - Django>=2.2 + Django>=3.2 python-ldap>=3.1 [flake8] diff --git a/tox.ini b/tox.ini index b5743d70..e905eb7c 100644 --- a/tox.ini +++ b/tox.ini @@ -4,7 +4,6 @@ envlist = flake8 isort docs - django22 django32 django40 djangomain @@ -13,7 +12,6 @@ isolated_build = true [testenv] commands = {envpython} -Wa -b -m django test --settings tests.settings deps = - django22: Django~=2.2.0 django32: Django>=3.2,<4.0 django40: Django>=4.0,<4.1 djangomain: https://github.com/django/django/archive/main.tar.gz From a6e03c6e4f793edbace8371ea4d42e56c5e833bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Freitag?= Date: Tue, 16 Aug 2022 12:13:07 +0200 Subject: [PATCH 06/11] Add support for Django 4.1 --- .github/workflows/test.yml | 1 + setup.cfg | 1 + tox.ini | 2 ++ 3 files changed, 4 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 38946427..db385535 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -19,6 +19,7 @@ jobs: tox-environment: - django32 - django40 + - django41 - djangomain include: - python-version: 3.7 diff --git a/setup.cfg b/setup.cfg index aad576ab..3ef31ad0 100644 --- a/setup.cfg +++ b/setup.cfg @@ -13,6 +13,7 @@ classifiers = Framework :: Django Framework :: Django :: 3.2 Framework :: Django :: 4.0 + Framework :: Django :: 4.1 Intended Audience :: Developers Intended Audience :: System Administrators License :: OSI Approved :: BSD License diff --git a/tox.ini b/tox.ini index e905eb7c..ac7bf29a 100644 --- a/tox.ini +++ b/tox.ini @@ -6,6 +6,7 @@ envlist = docs django32 django40 + django41 djangomain isolated_build = true @@ -14,6 +15,7 @@ commands = {envpython} -Wa -b -m django test --settings tests.settings deps = django32: Django>=3.2,<4.0 django40: Django>=4.0,<4.1 + django41: Django>=4.1,<4.2 djangomain: https://github.com/django/django/archive/main.tar.gz [testenv:black] From 78334206633091f66154365be26ebda2a65200db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Freitag?= Date: Tue, 16 Aug 2022 15:27:04 +0200 Subject: [PATCH 07/11] Simplify pyproject.toml https://code.djangoproject.com/ticket/33778 The wheel dependency is redundant and discouraged here. Setuptools adds this dependency via the backend automatically since day one. It was historically included in the documentation but it was a mistake. See: https://github.com/pypa/setuptools/commit/f7d30a9529378cf69054b5176249e5457aaf640a The legacy backend was never supposed to be used in pyproject.toml. It is only an "internal" fallback that is used by tools like pip when pyproject.toml is not present at all. The regular backend must always be used in pyproject.toml. See: https://github.com/pypa/setuptools/issues/1689 --- pyproject.toml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 417b3cff..b749ea1d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,10 +1,9 @@ [build-system] requires = [ "setuptools>=42", - "wheel", "setuptools_scm[toml]>=3.4", ] -build-backend = "setuptools.build_meta:__legacy__" +build-backend = "setuptools.build_meta" [tool.setuptools_scm] write_to = "django_auth_ldap/version.py" From 30f31bbfe87e37e97cf3688f9f338696c7dc1efc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Freitag?= Date: Mon, 27 Mar 2023 15:42:23 +0200 Subject: [PATCH 08/11] Add support for Python 3.11 --- .github/workflows/test.yml | 1 + setup.cfg | 1 + 2 files changed, 2 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index db385535..3dbbb5bc 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -16,6 +16,7 @@ jobs: - 3.8 - 3.9 - '3.10' + - '3.11' tox-environment: - django32 - django40 diff --git a/setup.cfg b/setup.cfg index 3ef31ad0..56942c98 100644 --- a/setup.cfg +++ b/setup.cfg @@ -24,6 +24,7 @@ classifiers = Programming Language :: Python :: 3.8 Programming Language :: Python :: 3.9 Programming Language :: Python :: 3.10 + Programming Language :: Python :: 3.11 Topic :: Internet :: WWW/HTTP Topic :: Software Development :: Libraries :: Python Modules Topic :: System :: Systems Administration :: Authentication/Directory :: LDAP From 5b5e26f8285d2dcab1db72bfe7c5365f8abd5d30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Freitag?= Date: Mon, 27 Mar 2023 15:52:06 +0200 Subject: [PATCH 09/11] Update test matrix --- .github/workflows/test.yml | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3dbbb5bc..3b44ea5c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -12,19 +12,37 @@ jobs: strategy: fail-fast: false matrix: + # https://docs.djangoproject.com/en/dev/faq/install/#what-python-version-can-i-use-with-django python-version: - 3.8 - 3.9 - '3.10' - '3.11' tox-environment: - - django32 - - django40 - django41 - - djangomain + - django42 include: + # Django 3.2 - python-version: 3.7 tox-environment: django32 + - python-version: 3.8 + tox-environment: django32 + - python-version: 3.9 + tox-environment: django32 + - python-version: '3.10' + tox-environment: django32 + # Django 4.0 + - python-version: 3.8 + tox-environment: django40 + - python-version: 3.9 + tox-environment: django40 + - python-version: '3.10' + tox-environment: django40 + # Django main + - python-version: '3.10' + tox-environment: djangomain + - python-version: '3.11' + tox-environment: djangomain env: TOXENV: ${{ matrix.tox-environment }} From 5cfa43a78078899b7493f9e72680c8fa7d0ae2ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Freitag?= Date: Tue, 28 Mar 2023 10:26:04 +0200 Subject: [PATCH 10/11] =?UTF-8?q?tox:=20whitelist=5Fexternals=20=E2=86=92?= =?UTF-8?q?=20allowlist=5Fexternals?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index ac7bf29a..74b8bef4 100644 --- a/tox.ini +++ b/tox.ini @@ -40,7 +40,7 @@ deps = sphinx commands = make -C docs html -whitelist_externals = make +allowlist_externals = make [testenv:packaging] deps = From 60f3983759ac04815b9034d5f15c7366bcdc2742 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Freitag?= Date: Tue, 28 Mar 2023 11:31:46 +0200 Subject: [PATCH 11/11] Update link to tox -e --- docs/contributing.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/contributing.rst b/docs/contributing.rst index df22cf24..724acde4 100644 --- a/docs/contributing.rst +++ b/docs/contributing.rst @@ -28,7 +28,7 @@ from the root of the project: This includes some static analysis to detect potential runtime errors and style issues. -To limit to a single environment, use :option:`tox.-e`: +To limit to a single environment, use :ref:`tox-run--e`: .. code-block:: console pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy