[Python-modules-commits] [django-python3-ldap] 01/04: Import django-python3-ldap_0.9.10.orig.tar.gz
Michael Fladischer
fladi at moszumanska.debian.org
Thu Jun 23 07:10:10 UTC 2016
This is an automated email from the git hooks/post-receive script.
fladi pushed a commit to branch master
in repository django-python3-ldap.
commit 2f5a8fc6deee237998f97f656616e9cfa4c56900
Author: Michael Fladischer <FladischerMichael at fladi.at>
Date: Thu Jun 23 08:56:40 2016 +0200
Import django-python3-ldap_0.9.10.orig.tar.gz
---
PKG-INFO | 5 ++-
README.rst | 38 ++++++++++++++++++++--
django_python3_ldap.egg-info/PKG-INFO | 5 ++-
django_python3_ldap/__init__.py | 2 +-
django_python3_ldap/ldap.py | 20 ++++++++----
.../management/commands/ldap_promote.py | 15 ++++++---
.../management/commands/ldap_sync_users.py | 6 ++--
setup.cfg | 2 +-
setup.py | 3 +-
9 files changed, 70 insertions(+), 26 deletions(-)
diff --git a/PKG-INFO b/PKG-INFO
index a026881..ac35472 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,6 +1,6 @@
Metadata-Version: 1.1
Name: django-python3-ldap
-Version: 0.9.9
+Version: 0.9.10
Summary: Django LDAP user authentication backend for Python 3.
Home-page: https://github.com/etianen/django-python3-ldap
Author: Dave Hall
@@ -15,7 +15,6 @@ Classifier: License :: OSI Approved :: BSD License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 2.7
-Classifier: Programming Language :: Python :: 3.2
-Classifier: Programming Language :: Python :: 3.3
Classifier: Programming Language :: Python :: 3.4
+Classifier: Programming Language :: Python :: 3.5
Classifier: Framework :: Django
diff --git a/README.rst b/README.rst
index 69df588..3774d8c 100644
--- a/README.rst
+++ b/README.rst
@@ -1,7 +1,7 @@
django-python3-ldap
===================
-**django-python3-ldap** provides a Django LDAP user authentication backend for Python 3.
+**django-python3-ldap** provides a Django LDAP user authentication backend for Python 2 and 3.
Features
@@ -10,7 +10,7 @@ Features
- Authenticate users with an LDAP server.
- Sync LDAP users with a local Django database.
- Supports custom Django user models.
-- Works in Python 3!
+- Works in Python 2 and 3!
Installation
@@ -21,11 +21,15 @@ Installation
3. Set your ``AUTHENTICATION_BACKENDS`` setting to ``("django_python3_ldap.auth.LDAPBackend",)``
4. Configure the settings for your LDAP server (see Available settings, below).
5. Optionally, run ``./manage.py ldap_sync_users`` to perform an initial sync of LDAP users.
+6. Optionally, run ``./manage.py ldap_promote <username>`` to grant superuser admin access to a given user.
Available settings
------------------
+**Note**: The settings below show their default values. You only need to add settings to your ``settings.py`` file that you intend to override.
+
+
.. code:: python
# The URL of the LDAP server.
@@ -100,6 +104,36 @@ then also specify:
LDAP_AUTH_ACTIVE_DIRECTORY_DOMAIN = "your_domain"
+Can't get authentication to work?
+---------------------------------
+
+LDAP is a very complicated protocol. Enable logging (see below), and see what error messages the LDAP connection is throwing.
+
+
+Logging
+-------
+
+Print information about failed logins to your console by adding the following to your ``settings.py`` file.
+
+.. code:: python
+
+ LOGGING = {
+ "version": 1,
+ "disable_existing_loggers": False,
+ "handlers": {
+ "console": {
+ "class": "logging.StreamHandler",
+ },
+ },
+ "loggers": {
+ "django_python3_ldap": {
+ "handlers": ["console"],
+ "level": "INFO",
+ },
+ },
+ }
+
+
Custom user filters
-------------------
diff --git a/django_python3_ldap.egg-info/PKG-INFO b/django_python3_ldap.egg-info/PKG-INFO
index a026881..ac35472 100644
--- a/django_python3_ldap.egg-info/PKG-INFO
+++ b/django_python3_ldap.egg-info/PKG-INFO
@@ -1,6 +1,6 @@
Metadata-Version: 1.1
Name: django-python3-ldap
-Version: 0.9.9
+Version: 0.9.10
Summary: Django LDAP user authentication backend for Python 3.
Home-page: https://github.com/etianen/django-python3-ldap
Author: Dave Hall
@@ -15,7 +15,6 @@ Classifier: License :: OSI Approved :: BSD License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 2.7
-Classifier: Programming Language :: Python :: 3.2
-Classifier: Programming Language :: Python :: 3.3
Classifier: Programming Language :: Python :: 3.4
+Classifier: Programming Language :: Python :: 3.5
Classifier: Framework :: Django
diff --git a/django_python3_ldap/__init__.py b/django_python3_ldap/__init__.py
index 239e5de..01d26d8 100644
--- a/django_python3_ldap/__init__.py
+++ b/django_python3_ldap/__init__.py
@@ -3,4 +3,4 @@ Django LDAP user authentication backend for Python 3.
"""
-__version__ = (0, 9, 9)
+__version__ = (0, 9, 10)
diff --git a/django_python3_ldap/ldap.py b/django_python3_ldap/ldap.py
index 2010d51..4a1e66f 100644
--- a/django_python3_ldap/ldap.py
+++ b/django_python3_ldap/ldap.py
@@ -3,6 +3,7 @@ Low-level LDAP hooks.
"""
import ldap3
+import logging
from contextlib import contextmanager
@@ -12,6 +13,9 @@ from django_python3_ldap.conf import settings
from django_python3_ldap.utils import import_func, format_search_filter
+logger = logging.getLogger(__name__)
+
+
class Connection(object):
"""
@@ -68,6 +72,7 @@ class Connection(object):
search_filter = format_search_filter({}),
search_scope = ldap3.SEARCH_SCOPE_WHOLE_SUBTREE,
attributes = ldap3.ALL_ATTRIBUTES,
+ get_operational_attributes = True,
paged_size = 30,
)
return (
@@ -118,17 +123,18 @@ def connection(**kwargs):
password = kwargs.pop("password")
username = import_func(settings.LDAP_AUTH_FORMAT_USERNAME)(kwargs)
# Make the connection.
- if username or password:
- if settings.LDAP_AUTH_USE_TLS:
- auto_bind = ldap3.AUTO_BIND_TLS_BEFORE_BIND
- else:
- auto_bind = ldap3.AUTO_BIND_NO_TLS
+ if settings.LDAP_AUTH_USE_TLS:
+ auto_bind = ldap3.AUTO_BIND_TLS_BEFORE_BIND
else:
- auto_bind = ldap3.AUTO_BIND_NONE
+ auto_bind = ldap3.AUTO_BIND_NO_TLS
try:
with ldap3.Connection(ldap3.Server(settings.LDAP_AUTH_URL), user=username, password=password, auto_bind=auto_bind) as c:
yield Connection(c)
- except (ldap3.LDAPBindError, ldap3.LDAPSASLPrepError):
+ except ldap3.LDAPBindError as ex:
+ logger.info("LDAP login failed: {ex}".format(ex=ex))
+ yield None
+ except ldap3.LDAPException as ex:
+ logger.warn("LDAP connect failed: {ex}".format(ex=ex))
yield None
diff --git a/django_python3_ldap/management/commands/ldap_promote.py b/django_python3_ldap/management/commands/ldap_promote.py
index 17cbd64..5080181 100644
--- a/django_python3_ldap/management/commands/ldap_promote.py
+++ b/django_python3_ldap/management/commands/ldap_promote.py
@@ -7,13 +7,20 @@ class Command(BaseCommand):
help = "Promotes the named users to an admin superuser."
- args = "[username, ...]"
+ def add_arguments(self, parser):
+ super(Command, self).add_arguments(parser)
+ parser.add_argument(
+ "usernames",
+ metavar="usernames",
+ nargs="*",
+ help="Usernames to promote to admin superuser.",
+ )
@transaction.atomic()
- def handle(self, *usernames, **kwargs):
- verbosity = int(kwargs.get("verbosity", 1))
+ def handle(self, **kwargs):
+ verbosity = kwargs["verbosity"]
User = get_user_model()
- for username in usernames:
+ for username in kwargs["usernames"]:
try:
user = User.objects.get(username=username)
except User.DoesNotExist:
diff --git a/django_python3_ldap/management/commands/ldap_sync_users.py b/django_python3_ldap/management/commands/ldap_sync_users.py
index a51cf3a..c18fa01 100644
--- a/django_python3_ldap/management/commands/ldap_sync_users.py
+++ b/django_python3_ldap/management/commands/ldap_sync_users.py
@@ -1,16 +1,16 @@
-from django.core.management.base import NoArgsCommand
+from django.core.management.base import BaseCommand
from django.db import transaction
from django_python3_ldap import ldap
from django_python3_ldap.conf import settings
-class Command(NoArgsCommand):
+class Command(BaseCommand):
help = "Creates local user models for all users found in the remote LDAP authentication server."
@transaction.atomic()
- def handle_noargs(self, **kwargs):
+ def handle(self, *args, **kwargs):
verbosity = int(kwargs.get("verbosity", 1))
with ldap.connection(username=settings.LDAP_AUTH_CONNECTION_USERNAME, password=settings.LDAP_AUTH_CONNECTION_PASSWORD) as connection:
for user in connection.iter_users():
diff --git a/setup.cfg b/setup.cfg
index 861a9f5..ebbec92 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -1,5 +1,5 @@
[egg_info]
tag_build =
-tag_date = 0
tag_svn_revision = 0
+tag_date = 0
diff --git a/setup.py b/setup.py
index 6e3767c..5313850 100644
--- a/setup.py
+++ b/setup.py
@@ -27,9 +27,8 @@ setup(
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 2.7",
- "Programming Language :: Python :: 3.2",
- "Programming Language :: Python :: 3.3",
"Programming Language :: Python :: 3.4",
+ "Programming Language :: Python :: 3.5",
"Framework :: Django",
],
)
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/django-python3-ldap.git
More information about the Python-modules-commits
mailing list