diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c3b61b5c..3b44ea5c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -12,22 +12,36 @@ 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: - - django22 - - django32 - - django40 + - django41 + - django42 include: + # Django 3.2 - python-version: 3.7 - tox-environment: django22 - - python-version: 3.7 + tox-environment: django32 + - python-version: 3.8 tox-environment: django32 - python-version: 3.9 - tox-environment: djangomain + 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: 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/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. 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. 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 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" diff --git a/setup.cfg b/setup.cfg index 63e5f7dc..56942c98 100644 --- a/setup.cfg +++ b/setup.cfg @@ -11,9 +11,9 @@ classifiers = Development Status :: 5 - Production/Stable Environment :: Web Environment Framework :: Django - Framework :: Django :: 2.2 Framework :: Django :: 3.2 Framework :: Django :: 4.0 + Framework :: Django :: 4.1 Intended Audience :: Developers Intended Audience :: System Administrators License :: OSI Approved :: BSD License @@ -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 @@ -36,7 +37,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 77df4f01..74b8bef4 100644 --- a/tox.ini +++ b/tox.ini @@ -4,17 +4,18 @@ envlist = flake8 isort docs - django22 django32 + django40 + django41 djangomain 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 + django41: Django>=4.1,<4.2 djangomain: https://github.com/django/django/archive/main.tar.gz [testenv:black] @@ -39,7 +40,7 @@ deps = sphinx commands = make -C docs html -whitelist_externals = make +allowlist_externals = make [testenv:packaging] deps = @@ -50,4 +51,4 @@ deps = skip_install = true commands = python -m build - twine check dist/* + twine check --strict dist/*
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: