[Python-modules-commits] [django-auth-ldap] 01/12: New upstream version 1.3.0

Michael Fladischer fladi at moszumanska.debian.org
Fri Nov 24 11:22:25 UTC 2017


This is an automated email from the git hooks/post-receive script.

fladi pushed a commit to branch debian/master
in repository django-auth-ldap.

commit 75fbddd58c27e5eba6c1dff47df5eba4b23e31e0
Author: Michael Fladischer <FladischerMichael at fladi.at>
Date:   Fri Nov 24 10:58:23 2017 +0100

    New upstream version 1.3.0
---
 CHANGES                                     | 119 +++++---
 MANIFEST.in                                 |   5 +-
 PKG-INFO                                    |  17 +-
 README                                      |  67 -----
 README.md                                   | 168 +++++++++++
 django_auth_ldap.egg-info/PKG-INFO          |  17 +-
 django_auth_ldap.egg-info/SOURCES.txt       |  42 +--
 django_auth_ldap.egg-info/requires.txt      |   7 +-
 django_auth_ldap/__init__.py                |   8 +-
 django_auth_ldap/backend.py                 | 364 +++++++++++------------
 django_auth_ldap/config.py                  |  81 ++---
 django_auth_ldap/dn.py                      |   2 +
 django_auth_ldap/models.py                  |  32 --
 docs/.Makefile.swp                          | Bin 12288 -> 0 bytes
 docs/Makefile                               |  99 +------
 docs/_templates/globaltoc.html              |  11 -
 docs/ext/.daldocs.py.swp                    | Bin 12288 -> 0 bytes
 docs/ext/__pycache__/daldocs.cpython-36.pyc | Bin 0 -> 415 bytes
 docs/make.bat                               |  36 +++
 docs/source/.authentication.rst.swp         | Bin 16384 -> 0 bytes
 docs/source/.changes.rst.swp                | Bin 12288 -> 0 bytes
 docs/source/.conf.py.swp                    | Bin 20480 -> 0 bytes
 docs/source/.contributing.rst.swp           | Bin 12288 -> 0 bytes
 docs/source/.index.rst.swp                  | Bin 12288 -> 0 bytes
 docs/source/.install.rst.swp                | Bin 12288 -> 0 bytes
 docs/source/authentication.rst              |  25 ++
 docs/source/conf.py                         | 238 +++++++--------
 docs/source/contributing.rst                |  29 --
 docs/source/example.rst                     |   8 -
 docs/source/index.rst                       |   7 +-
 docs/source/install.rst                     |  39 ++-
 docs/source/performance.rst                 |  47 ++-
 docs/source/reference.rst                   | 119 ++++----
 docs/source/users.rst                       |  60 ++--
 setup.cfg                                   |   6 +
 setup.py                                    |  89 +++++-
 test/.coveragerc                            |   4 -
 test/.settings.py.swp                       | Bin 12288 -> 0 bytes
 test/manage.py                              |  12 -
 test/urls.py                                |   7 -
 tests/__init__.py                           |   0
 tests/__init__.pyc                          | Bin 0 -> 148 bytes
 tests/__pycache__/__init__.cpython-34.pyc   | Bin 0 -> 144 bytes
 tests/__pycache__/__init__.cpython-35.pyc   | Bin 0 -> 144 bytes
 tests/__pycache__/__init__.cpython-36.pyc   | Bin 0 -> 144 bytes
 tests/__pycache__/models.cpython-34.pyc     | Bin 0 -> 1329 bytes
 tests/__pycache__/models.cpython-35.pyc     | Bin 0 -> 1329 bytes
 tests/__pycache__/models.cpython-36.pyc     | Bin 0 -> 1256 bytes
 tests/__pycache__/settings.cpython-34.pyc   | Bin 0 -> 880 bytes
 tests/__pycache__/settings.cpython-35.pyc   | Bin 0 -> 876 bytes
 tests/__pycache__/settings.cpython-36.pyc   | Bin 0 -> 836 bytes
 tests/__pycache__/tests.cpython-34.pyc      | Bin 0 -> 54907 bytes
 tests/__pycache__/tests.cpython-35.pyc      | Bin 0 -> 54753 bytes
 tests/__pycache__/tests.cpython-36.pyc      | Bin 0 -> 49947 bytes
 tests/models.py                             |  25 ++
 tests/models.pyc                            | Bin 0 -> 1631 bytes
 {test => tests}/settings.py                 |   9 +-
 tests/settings.pyc                          | Bin 0 -> 1074 bytes
 {django_auth_ldap => tests}/tests.py        | 445 ++++++++++++++++------------
 tests/tests.pyc                             | Bin 0 -> 62783 bytes
 tox.ini                                     |  49 ++-
 61 files changed, 1223 insertions(+), 1070 deletions(-)

diff --git a/CHANGES b/CHANGES
index 0b9e6d9..2d9c321 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,5 +1,44 @@
-v1.2.15 - 2017-08-17 - Documentation improvements
--------------------------------------------------
+1.3.0 - 2017-11-20 - Various improvements and cleanup
+-----------------------------------------------------
+
+This release driven primarily by https://bitbucket.org/jdufresne/.
+
+- **Backwards incompatible**: Removed support for obsolete versions of
+  Django (<=1.7, plus 1.9).
+
+- Fix `#58`_: Delay saving new users as long as possible. This will allow
+  :setting:`AUTH_LDAP_USER_ATTR_MAP` to populate required fields before creating
+  a new Django user.
+
+  ``LDAPBackend.get_or_create_user()`` is now
+  :meth:`~django_auth_ldap.backend.LDAPBackend.get_or_build_user` to avoid
+  confusion. The old name may still be overridden for now.
+
+- Support querying by a field other than the username field with
+  :setting:`AUTH_LDAP_USER_QUERY_FIELD`.
+
+- New method
+  :meth:`~django_auth_ldap.backend.LDAPBackend.authenticate_ldap_user()` to
+  provide pre- and post-authenication hooks.
+
+- Add support for Django 2.0.
+
+.. _#58: https://bitbucket.org/illocution/django-auth-ldap/issues/58/
+
+
+1.2.16 - 2017-09-30 - Minor fixes
+---------------------------------
+
+- Fix `#86`_: Better cache key sanitizing.
+
+- Improved handling of LDAPError. A case existed where the error would not get
+  caught while loading group permissions.
+
+.. _#86: https://bitbucket.org/illocution/django-auth-ldap/issues/86/
+
+
+1.2.15 - 2017-08-17 - Documentation improvements
+------------------------------------------------
 
 - Fix `#83`_: Improved documentation for finding the official repository and
   contributing.
@@ -7,8 +46,8 @@ v1.2.15 - 2017-08-17 - Documentation improvements
 .. _#83: https://bitbucket.org/illocution/django-auth-ldap/issues/83/
 
 
-v1.2.14 - 2017-07-24 - User DN caching
---------------------------------------
+1.2.14 - 2017-07-24 - User DN caching
+-------------------------------------
 
 - Fix `#82`_: Under search/bind mode, the user's DN will now be cached for
   performance.
@@ -16,8 +55,8 @@ v1.2.14 - 2017-07-24 - User DN caching
 .. _#82: https://bitbucket.org/illocution/django-auth-ldap/issues/82/
 
 
-v1.2.13 - 2017-06-19 - Selective group mirroring
-------------------------------------------------
+1.2.13 - 2017-06-19 - Selective group mirroring
+-----------------------------------------------
 
 - Support selective group mirroring with :setting:`AUTH_LDAP_MIRROR_GROUPS` and
   :setting:`AUTH_LDAP_MIRROR_GROUPS_EXCEPT`.
@@ -27,23 +66,23 @@ v1.2.13 - 2017-06-19 - Selective group mirroring
 .. _#73: https://bitbucket.org/illocution/django-auth-ldap/issues/73/
 
 
-v1.2.12 - 2017-05-20 - Complex group queries
---------------------------------------------
+1.2.12 - 2017-05-20 - Complex group queries
+-------------------------------------------
 
 - Support for complex group queries via
   :class:`~django_auth_ldap.config.LDAPGroupQuery`.
 
 
-v1.2.11 - 2017-04-22 - Testing and debugging cleanup
-----------------------------------------------------
+1.2.11 - 2017-04-22 - Testing and debugging cleanup
+---------------------------------------------------
 
 - Some more descriptive object representations.
 
 - Improved tox.ini organization.
 
 
-v1.2.9 - 2017-02-14 - Fix python-ldap incompatibility
------------------------------------------------------
+1.2.9 - 2017-02-14 - Fix python-ldap incompatibility
+----------------------------------------------------
 
 - Fix `#65`_: Ignore python-ldap documentation and accept
   :data:`ldap.RES_SEARCH_ENTRY` from :meth:`ldap.LDAPObject.result`.
@@ -51,21 +90,21 @@ v1.2.9 - 2017-02-14 - Fix python-ldap incompatibility
 .. _#65: https://bitbucket.org/illocution/django-auth-ldap/issues/65/
 
 
-v1.2.8 - 2016-04-18 - AUTH_LDAP_USER_ATTRLIST
----------------------------------------------
+1.2.8 - 2016-04-18 - AUTH_LDAP_USER_ATTRLIST
+--------------------------------------------
 
 - Add :setting:`AUTH_LDAP_USER_ATTRLIST` to override the set of attributes
   requested from the LDAP server.
 
 
-v1.2.7 - 2015-09-29 - Python 3
-------------------------------
+1.2.7 - 2015-09-29 - Python 3
+-----------------------------
 
 - Support Python 3 with `pyldap <https://pypi.python.org/pypi/pyldap>`_.
 
 
-v1.2.6 - 2015-03-29
--------------------
+1.2.6 - 2015-03-29
+------------------
 
 - Performance improvements to group mirroring (from
   `Denver Janke <https://bitbucket.org/denverjanke>`_).
@@ -77,21 +116,21 @@ v1.2.6 - 2015-03-29
   per-subclass default settings.
 
 
-v1.2.5 - 2015-01-30
--------------------
+1.2.5 - 2015-01-30
+------------------
 
 - Fix interaction between :setting:`AUTH_LDAP_AUTHORIZE_ALL_USERS` and
   :setting:`AUTH_LDAP_USER_SEARCH`.
 
 
-v1.2.4 - 2014-12-28 - nisNetgroup support
------------------------------------------
+1.2.4 - 2014-12-28 - nisNetgroup support
+----------------------------------------
 
 - Add support for nisNetgroup groups (thanks to Christopher Bartz).
 
 
-v1.2.3 - 2014-11-18
--------------------
+1.2.3 - 2014-11-18
+------------------
 
 - Fix `#50`_: Improved escaping for filter strings.
 
@@ -101,21 +140,21 @@ v1.2.3 - 2014-11-18
 .. _#50: https://bitbucket.org/illocution/django-auth-ldap/issue/50/
 
 
-v1.2.2 - 2014-09-22
--------------------
+1.2.2 - 2014-09-22
+------------------
 
 - Include test harness in source distribution. Some package maintainers find
   this helpful.
 
 
-v1.2.1 - 2014-08-24
--------------------
+1.2.1 - 2014-08-24
+------------------
 
 - More verbose log messages for authentication failures.
 
 
-v1.2 - 2014-04-10
------------------
+1.2 - 2014-04-10
+----------------
 
 - django-auth-ldap now provides experimental Python 3 support. Python 2.5 was
   dropped.
@@ -130,8 +169,8 @@ v1.2 - 2014-04-10
   Thanks to `Aymeric Augustin <https://myks.org/en/>`_ for making this happen.
 
 
-v1.1.8 - 2014-02-01
--------------------
+1.1.8 - 2014-02-01
+------------------
 
 * Fix `#43`_: Update :class:`~django_auth_ldap.config.LDAPSearchUnion` to work for
   group searches in addition to user searches.
@@ -141,15 +180,15 @@ v1.1.8 - 2014-02-01
 .. _#43: https://bitbucket.org/illocution/django-auth-ldap/issue/43/
 
 
-v1.1.7 - 2013-11-19
--------------------
+1.1.7 - 2013-11-19
+------------------
 
 * Bug fix: :setting:`AUTH_LDAP_GLOBAL_OPTIONS` could be ignored in some cases
   (such as :func:`~django_auth_ldap.backend.LDAPBackend.populate_user`).
 
 
-v1.1.5 - 2013-10-25
--------------------
+1.1.5 - 2013-10-25
+------------------
 
 * Fix `#41`_: Support POSIX group permissions with no gidNumber attribute.
 
@@ -159,14 +198,14 @@ v1.1.5 - 2013-10-25
 .. _#41: https://bitbucket.org/illocution/django-auth-ldap/issue/41/
 
 
-v1.1.4 - 2013-03-09
--------------------
+1.1.4 - 2013-03-09
+------------------
 
 * Add support for Django 1.5's custom user models.
 
 
-v1.1.3 - 2013-01-05
--------------------
+1.1.3 - 2013-01-05
+------------------
 
 * Fix `#33`_: Reject empty passwords by default.
 
diff --git a/MANIFEST.in b/MANIFEST.in
index e375a0c..571a810 100644
--- a/MANIFEST.in
+++ b/MANIFEST.in
@@ -1,7 +1,6 @@
-include README LICENSE CHANGES
+include README.md LICENSE CHANGES
 include tox.ini
 
 recursive-include docs *
-recursive-include test *
+recursive-include tests *
 prune docs/build
-global-exclude *.pyc .DS_Store .workon
diff --git a/PKG-INFO b/PKG-INFO
index 56fe30a..a88f08a 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,24 +1,25 @@
 Metadata-Version: 1.1
 Name: django-auth-ldap
-Version: 1.2.15
+Version: 1.3.0
 Summary: Django LDAP authentication backend
-Home-page: http://bitbucket.org/illocution/django-auth-ldap
+Home-page: https://bitbucket.org/illocution/django-auth-ldap
 Author: Peter Sagerson
 Author-email: psagers at ignorare.net
 License: BSD
+Description-Content-Type: UNKNOWN
 Description: This is a Django authentication backend that authenticates against an LDAP
         service. Configuration can be as simple as a single distinguished name template,
         but there are many rich configuration options for working with users, groups,
         and permissions.
         
-        This version is supported on Python 2.7, 3.3, 3.4, 3.5, and 3.6; and Django >=
-        1.5. Under Python 2, it requires `python-ldap
+        This version is supported on Python 2.7 and 3.4+; and Django 1.8 and 1.10+.
+        Under Python 2, it requires `python-ldap
         <https://pypi.python.org/pypi/python-ldap>`_ >= 2.0; under Python 3, it uses
         `pyldap <https://pypi.python.org/pypi/pyldap>`_.
         
         * Repository: https://bitbucket.org/illocution/django-auth-ldap
         * Documentation: https://django-auth-ldap.readthedocs.io/
-        * Mailing list: http://groups.google.com/group/django-auth-ldap
+        * Mailing list: https://groups.google.com/group/django-auth-ldap
         
         Following is an example configuration, just to whet your appetite::
         
@@ -82,18 +83,14 @@ Classifier: Programming Language :: Python
 Classifier: Programming Language :: Python :: 2
 Classifier: Programming Language :: Python :: 2.7
 Classifier: Programming Language :: Python :: 3
-Classifier: Programming Language :: Python :: 3.3
 Classifier: Programming Language :: Python :: 3.4
 Classifier: Programming Language :: Python :: 3.5
 Classifier: Programming Language :: Python :: 3.6
 Classifier: Framework :: Django
-Classifier: Framework :: Django :: 1.5
-Classifier: Framework :: Django :: 1.6
-Classifier: Framework :: Django :: 1.7
 Classifier: Framework :: Django :: 1.8
-Classifier: Framework :: Django :: 1.9
 Classifier: Framework :: Django :: 1.10
 Classifier: Framework :: Django :: 1.11
+Classifier: Framework :: Django :: 2.0
 Classifier: Intended Audience :: Developers
 Classifier: Intended Audience :: System Administrators
 Classifier: License :: OSI Approved :: BSD License
diff --git a/README b/README
deleted file mode 100644
index b1eeffd..0000000
--- a/README
+++ /dev/null
@@ -1,67 +0,0 @@
-This is a Django authentication backend that authenticates against an LDAP
-service. Configuration can be as simple as a single distinguished name template,
-but there are many rich configuration options for working with users, groups,
-and permissions.
-
-This version is supported on Python 2.7, 3.3, 3.4, 3.5, and 3.6; and Django >=
-1.5. Under Python 2, it requires `python-ldap
-<https://pypi.python.org/pypi/python-ldap>`_ >= 2.0; under Python 3, it uses
-`pyldap <https://pypi.python.org/pypi/pyldap>`_.
-
-* Repository: https://bitbucket.org/illocution/django-auth-ldap
-* Documentation: https://django-auth-ldap.readthedocs.io/
-* Mailing list: http://groups.google.com/group/django-auth-ldap
-
-Following is an example configuration, just to whet your appetite::
-
-    import ldap
-    from django_auth_ldap.config import LDAPSearch, GroupOfNamesType
-
-
-    # Baseline configuration.
-    AUTH_LDAP_SERVER_URI = "ldap://ldap.example.com"
-
-    AUTH_LDAP_BIND_DN = "cn=django-agent,dc=example,dc=com"
-    AUTH_LDAP_BIND_PASSWORD = "phlebotinum"
-    AUTH_LDAP_USER_SEARCH = LDAPSearch("ou=users,dc=example,dc=com",
-        ldap.SCOPE_SUBTREE, "(uid=%(user)s)")
-    # or perhaps:
-    # AUTH_LDAP_USER_DN_TEMPLATE = "uid=%(user)s,ou=users,dc=example,dc=com"
-
-    # Set up the basic group parameters.
-    AUTH_LDAP_GROUP_SEARCH = LDAPSearch("ou=django,ou=groups,dc=example,dc=com",
-        ldap.SCOPE_SUBTREE, "(objectClass=groupOfNames)"
-    )
-    AUTH_LDAP_GROUP_TYPE = GroupOfNamesType()
-
-    # Simple group restrictions
-    AUTH_LDAP_REQUIRE_GROUP = "cn=enabled,ou=django,ou=groups,dc=example,dc=com"
-    AUTH_LDAP_DENY_GROUP = "cn=disabled,ou=django,ou=groups,dc=example,dc=com"
-
-    # Populate the Django user from the LDAP directory.
-    AUTH_LDAP_USER_ATTR_MAP = {
-        "first_name": "givenName",
-        "last_name": "sn",
-        "email": "mail"
-    }
-
-    AUTH_LDAP_USER_FLAGS_BY_GROUP = {
-        "is_active": "cn=active,ou=django,ou=groups,dc=example,dc=com",
-        "is_staff": "cn=staff,ou=django,ou=groups,dc=example,dc=com",
-        "is_superuser": "cn=superuser,ou=django,ou=groups,dc=example,dc=com"
-    }
-
-    # Use LDAP group membership to calculate group permissions.
-    AUTH_LDAP_FIND_GROUP_PERMS = True
-
-    # Cache group memberships for an hour to minimize LDAP traffic
-    AUTH_LDAP_CACHE_GROUPS = True
-    AUTH_LDAP_GROUP_CACHE_TIMEOUT = 3600
-
-
-    # Keep ModelBackend around for per-user permissions and maybe a local
-    # superuser.
-    AUTHENTICATION_BACKENDS = (
-        'django_auth_ldap.backend.LDAPBackend',
-        'django.contrib.auth.backends.ModelBackend',
-    )
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..ebbe6e5
--- /dev/null
+++ b/README.md
@@ -0,0 +1,168 @@
+# django-auth-ldap
+
+This is a Django authentication backend that authenticates against an LDAP
+service. Configuration can be as simple as a single distinguished name template,
+but there are many rich configuration options for working with users, groups,
+and permissions.
+
+This version is supported on Python 2.7 and 3.4+; and Django 1.8 and 1.10+.
+Under Python 2, it requires [python-ldap][] >= 2.0; under Python 3, it uses
+[pyldap][].
+
+* Repository: https://bitbucket.org/illocution/django-auth-ldap
+* Documentation: https://django-auth-ldap.readthedocs.io/
+* Mailing list: https://groups.google.com/group/django-auth-ldap
+
+
+## History and Status
+
+As with so many efforts of this type, this is a minor side project that I spun
+out of a private Django deployment. The BSD license, in many ways a formality,
+is also a pretty accurate description of the project's motivation and status:
+"Here's a thing I did. I found it useful, maybe you will too. Do whatever you
+like with it."
+
+Although this library has long done everything I need it to, I continue to
+maintain it as a small contribution to the Django community. Important bugs I
+try to process fairly quickly. Less urgent issues may queue up until I can break
+away from other work.
+
+
+## Contributing
+
+If you'd like to report an issue or contribute a feature, but you're not sure
+how to proceed, start with the [mailing list][]. This may clear up some
+misunderstandings or provide a gut check on how feasible the idea is.
+
+If you have something concrete you'd like to contribute, the best approach is to
+send a well-formed pull request, complete with tests and documentation, as
+needed. Pull requests that lack tests or documentation or that break existing
+tests will probably not be taken very seriously. Pull requests should also be
+focused: trying to do more than one thing in a single request will make it more
+difficult to process.
+
+If you have a bug or feature request that you can't or don't wish to fix or
+implement, you can try [logging an issue][issues]. Serious bugs should get taken
+care of quickly, but less urgent issues may or may not attract any attention. It
+just depends on whether anyone else finds it interesting enough to do something
+about.
+
+There's no harm in creating an issue and then submitting a pull request to
+resolve it. This can be a good way to start a conversation and can serve as an
+anchor point if the initial pull request turns out not to be the best approach.
+
+Here are a few dos and don'ts to help us all save some time.
+
+* **Don't** move fast and break stuff.
+
+* **Do** propose incremental fixes or improvements that solve well-defined
+  problems with minimal collatoral effects.
+
+* **Do** feel free to do a bit of syntactic cleanup, especially when it comes to
+  leaving behind obsolete Python or Django versions. This project goes back at
+  least to Python 2.3 and Django 1.0; youngins may find some lingering
+  anachronisms disorienting.
+
+* **Don't** do a bunch of semantic cleanup without a clear and compelling
+  reason. The phrase "I don't see how this could break anything" is a confession
+  of the ignorance and uncertainty under which we all labor, not a proof of
+  correctness.
+
+* **Do** reach out if you'd like a feature or change and you're not sure how to
+  proceed.
+
+
+## Development
+
+To get set up for development, activate your virtualenv and use pip to install
+from requirements-dev.txt:
+
+    % pip install -r requirements-dev.txt
+
+To run the tests:
+
+    % django-admin test --settings tests.settings
+
+To run the full test suite in a range of environments, run [tox][] from the root
+of the project:
+
+    % tox
+
+This includes some static analysis to detect potential runtime errors and style
+issues.
+
+
+## Mercurial
+
+django-auth-ldap uses [Mercurial][hg] for source control. If you're more
+familiar with Git, Mercurial is similar in many ways, but there are a few
+important differences to keep in mind.
+
+Mercurial branches are more or less permanent and thus not very good for feature
+work or pull requests. If you want to work on multiple features at once, use
+[bookmarks][hg-bookmark] or [topics][hg-topic] instead (Bitbucket may not
+recognize topics yet). The default bookmark is called ``@`` (similar to git's
+master branch).
+
+    % hg up @
+    % hg bookmark new-feature
+    (make changes)
+    % hg ci
+    % hg push -B new-feature
+
+Local Mercurial clones and Bitbucket forks are all (typically)
+[non-publishing][hg-non-publishing] repositories. This means that new
+changesets remain in draft mode and can be modified in a safe and principled
+manner with the [evolve][hg-evolve-ext] extension. I make heavy use of
+[changeset evolution][hg-evolution] and frequently rely it to process pull
+requests while keeping the history clean and linear.
+
+If you're setting up Mercurial for the first time, I recommend you make sure you
+have the latest version and install [hg-evolve][pypi-evolve] with it. Here's a
+sample ~/.hgrc to get started:
+
+    [ui]
+    username = Your Name <youremail at example.com>
+    ignore = ~/.hgignore
+    style = phases
+
+    [extensions]
+    color =
+    evolve =
+    histedit =
+    rebase =
+    shelve =
+    topic =
+
+    [alias]
+    glog = log --graph
+
+You should also go to the Labs section of your bitbucket.org account settings
+and turn on evolution support.
+
+Changeset evolution is a big topic, but one of the most useful things to know is
+that it's safe to amend existing draft changesets even if they've already been
+shared with other non-publishing repositories:
+
+    % hg up @
+    % hg bookmark new-feature
+    (make changes)
+    % hg ci
+    % hg push -B new-feature
+    (incorporate feedback)
+    % hg amend
+    % hg push
+
+
+[python-ldap]: https://pypi.python.org/pypi/python-ldap
+[pyldap]: https://pypi.python.org/pypi/pyldap
+[mailing list]: https://groups.google.com/group/django-auth-ldap 
+[issues]: https://bitbucket.org/illocution/django-auth-ldap/issues?status=new&status=open
+[tox]: https://tox.readthedocs.io/
+[hg]: https://www.mercurial-scm.org/
+[hg-bookmark]: https://www.mercurial-scm.org/wiki/Bookmarks
+[hg-topic]: https://www.mercurial-scm.org/doc/evolution/tutorials/topic-tutorial.html
+[hg-non-publishing]: https://www.mercurial-scm.org/wiki/Phases#Publishing_Repository
+[hg-evolve-ext]: https://www.mercurial-scm.org/wiki/EvolveExtension
+[hg-evolution]: https://www.mercurial-scm.org/doc/evolution/
+[pypi-evolve]: https://pypi.python.org/pypi/hg-evolve
diff --git a/django_auth_ldap.egg-info/PKG-INFO b/django_auth_ldap.egg-info/PKG-INFO
index 56fe30a..a88f08a 100644
--- a/django_auth_ldap.egg-info/PKG-INFO
+++ b/django_auth_ldap.egg-info/PKG-INFO
@@ -1,24 +1,25 @@
 Metadata-Version: 1.1
 Name: django-auth-ldap
-Version: 1.2.15
+Version: 1.3.0
 Summary: Django LDAP authentication backend
-Home-page: http://bitbucket.org/illocution/django-auth-ldap
+Home-page: https://bitbucket.org/illocution/django-auth-ldap
 Author: Peter Sagerson
 Author-email: psagers at ignorare.net
 License: BSD
+Description-Content-Type: UNKNOWN
 Description: This is a Django authentication backend that authenticates against an LDAP
         service. Configuration can be as simple as a single distinguished name template,
         but there are many rich configuration options for working with users, groups,
         and permissions.
         
-        This version is supported on Python 2.7, 3.3, 3.4, 3.5, and 3.6; and Django >=
-        1.5. Under Python 2, it requires `python-ldap
+        This version is supported on Python 2.7 and 3.4+; and Django 1.8 and 1.10+.
+        Under Python 2, it requires `python-ldap
         <https://pypi.python.org/pypi/python-ldap>`_ >= 2.0; under Python 3, it uses
         `pyldap <https://pypi.python.org/pypi/pyldap>`_.
         
         * Repository: https://bitbucket.org/illocution/django-auth-ldap
         * Documentation: https://django-auth-ldap.readthedocs.io/
-        * Mailing list: http://groups.google.com/group/django-auth-ldap
+        * Mailing list: https://groups.google.com/group/django-auth-ldap
         
         Following is an example configuration, just to whet your appetite::
         
@@ -82,18 +83,14 @@ Classifier: Programming Language :: Python
 Classifier: Programming Language :: Python :: 2
 Classifier: Programming Language :: Python :: 2.7
 Classifier: Programming Language :: Python :: 3
-Classifier: Programming Language :: Python :: 3.3
 Classifier: Programming Language :: Python :: 3.4
 Classifier: Programming Language :: Python :: 3.5
 Classifier: Programming Language :: Python :: 3.6
 Classifier: Framework :: Django
-Classifier: Framework :: Django :: 1.5
-Classifier: Framework :: Django :: 1.6
-Classifier: Framework :: Django :: 1.7
 Classifier: Framework :: Django :: 1.8
-Classifier: Framework :: Django :: 1.9
 Classifier: Framework :: Django :: 1.10
 Classifier: Framework :: Django :: 1.11
+Classifier: Framework :: Django :: 2.0
 Classifier: Intended Audience :: Developers
 Classifier: Intended Audience :: System Administrators
 Classifier: License :: OSI Approved :: BSD License
diff --git a/django_auth_ldap.egg-info/SOURCES.txt b/django_auth_ldap.egg-info/SOURCES.txt
index a549154..247645d 100644
--- a/django_auth_ldap.egg-info/SOURCES.txt
+++ b/django_auth_ldap.egg-info/SOURCES.txt
@@ -1,37 +1,28 @@
 CHANGES
 LICENSE
 MANIFEST.in
-README
+README.md
+setup.cfg
 setup.py
 tox.ini
 django_auth_ldap/__init__.py
 django_auth_ldap/backend.py
 django_auth_ldap/config.py
 django_auth_ldap/dn.py
-django_auth_ldap/models.py
-django_auth_ldap/tests.py
 django_auth_ldap.egg-info/PKG-INFO
 django_auth_ldap.egg-info/SOURCES.txt
 django_auth_ldap.egg-info/dependency_links.txt
 django_auth_ldap.egg-info/requires.txt
 django_auth_ldap.egg-info/top_level.txt
-docs/.Makefile.swp
 docs/Makefile
-docs/_templates/globaltoc.html
-docs/ext/.daldocs.py.swp
+docs/make.bat
 docs/ext/daldocs.py
-docs/source/.authentication.rst.swp
-docs/source/.changes.rst.swp
-docs/source/.conf.py.swp
-docs/source/.contributing.rst.swp
-docs/source/.index.rst.swp
-docs/source/.install.rst.swp
+docs/ext/__pycache__/daldocs.cpython-36.pyc
 docs/source/.spell.utf-8.add
 docs/source/.spell.utf-8.add.spl
 docs/source/authentication.rst
 docs/source/changes.rst
 docs/source/conf.py
-docs/source/contributing.rst
 docs/source/example.rst
 docs/source/groups.rst
 docs/source/index.rst
@@ -42,8 +33,23 @@ docs/source/performance.rst
 docs/source/permissions.rst
 docs/source/reference.rst
 docs/source/users.rst
-test/.coveragerc
-test/.settings.py.swp
-test/manage.py
-test/settings.py
-test/urls.py
\ No newline at end of file
+tests/__init__.py
+tests/__init__.pyc
+tests/models.py
+tests/models.pyc
+tests/settings.py
+tests/settings.pyc
+tests/tests.py
+tests/tests.pyc
+tests/__pycache__/__init__.cpython-34.pyc
+tests/__pycache__/__init__.cpython-35.pyc
+tests/__pycache__/__init__.cpython-36.pyc
+tests/__pycache__/models.cpython-34.pyc
+tests/__pycache__/models.cpython-35.pyc
+tests/__pycache__/models.cpython-36.pyc
+tests/__pycache__/settings.cpython-34.pyc
+tests/__pycache__/settings.cpython-35.pyc
+tests/__pycache__/settings.cpython-36.pyc
+tests/__pycache__/tests.cpython-34.pyc
+tests/__pycache__/tests.cpython-35.pyc
+tests/__pycache__/tests.cpython-36.pyc
\ No newline at end of file
diff --git a/django_auth_ldap.egg-info/requires.txt b/django_auth_ldap.egg-info/requires.txt
index 8f1fe2c..38bc06c 100644
--- a/django_auth_ldap.egg-info/requires.txt
+++ b/django_auth_ldap.egg-info/requires.txt
@@ -1,2 +1,7 @@
-django
+django>=1.8
+
+[:python_version < "3.0"]
+python-ldap>=2.0
+
+[:python_version >= "3.0"]
 pyldap
diff --git a/django_auth_ldap/__init__.py b/django_auth_ldap/__init__.py
index 89fb7c4..be46dcc 100644
--- a/django_auth_ldap/__init__.py
+++ b/django_auth_ldap/__init__.py
@@ -1,2 +1,6 @@
-version = (1, 2, 15)
-version_string = '.'.join(map(str, version))
+from __future__ import absolute_import, division, print_function, unicode_literals
+
+
+version = (1, 3, 0)
+version_qualifier = ''
+version_string = '.'.join(map(str, version)) + version_qualifier
diff --git a/django_auth_ldap/backend.py b/django_auth_ldap/backend.py
index 35806a6..ecbff16 100644
--- a/django_auth_ldap/backend.py
+++ b/django_auth_ldap/backend.py
@@ -45,51 +45,28 @@ information will be user_dn or user_info.
 Additional classes can be found in the config module next to this one.
 """
 
+from __future__ import absolute_import, division, print_function, unicode_literals
+
 import copy
 from functools import reduce
-import ldap
 import operator
 import pprint
-import sys
-import traceback
+import re
 import warnings
 
-from django.contrib.auth.models import User, Group, Permission
+import ldap
+
+import django
 import django.conf
+from django.contrib.auth import get_user_model
+from django.contrib.auth.models import Group, Permission
 from django.core.cache import cache
 from django.core.exceptions import ImproperlyConfigured, ObjectDoesNotExist
 import django.dispatch
-try:
-    from django.utils.encoding import force_str
-except ImportError:  # Django < 1.5
-    from django.utils.encoding import smart_str as force_str
-
-# Django 1.7 Removed custom profiles
-try:
-    from django.contrib.auth.models import SiteProfileNotAvailable
-except ImportError:
-    SiteProfileNotAvailable = Exception
+from django.utils import six
+from django.utils.encoding import force_str
 
-# Support Django 1.5's custom user models
-try:
-    from django.contrib.auth import get_user_model
-
-    def get_user_username(user):
-        return user.get_username()
-except ImportError:
-    def get_user_model():
-        return User
-
-    def get_user_username(user):
-        return user.username
-
-# Small compatibility hack
-try:
-    basestring
-except NameError:
-    basestring = str
-
-from django_auth_ldap.config import ConfigurationWarning, _LDAPConfig, LDAPGroupQuery, LDAPSearch
+from django_auth_ldap.config import ConfigurationWarning, LDAPGroupQuery, LDAPSearch, _LDAPConfig
 
 
 logger = _LDAPConfig.get_logger()
@@ -97,13 +74,12 @@ logger = _LDAPConfig.get_logger()
 
 # Exported signals
 
-# Allows clients to perform custom user/profile population.
+# Allows clients to perform custom user population.
 populate_user = django.dispatch.Signal(providing_args=["user", "ldap_user"])
-populate_user_profile = django.dispatch.Signal(providing_args=["profile", "ldap_user"])
 
 # Allows clients to inspect and perform special handling of LDAPError
 # exceptions. Exceptions raised by handlers will be propagated out.
-ldap_error = django.dispatch.Signal(providing_args=['context', 'exception'])
+ldap_error = django.dispatch.Signal(providing_args=['context', 'user', 'exception'])
 
 
 class LDAPBackend(object):
@@ -130,29 +106,29 @@ class LDAPBackend(object):
         """
         Exclude certain cached properties from pickling.
         """
-        return dict((k, v) for (k, v) in self.__dict__.items()
-                    if k not in ['_settings', '_ldap'])
+        return {k: v for k, v in self.__dict__.items()
+                if k not in ['_settings', '_ldap']}
 
-    def _get_settings(self):
+    @property
+    def settings(self):
         if self._settings is None:
             self._settings = LDAPSettings(self.settings_prefix,
                                           self.default_settings)
 
         return self._settings
 
-    def _set_settings(self, settings):
+    @settings.setter
+    def settings(self, settings):
         self._settings = settings
 
-    settings = property(_get_settings, _set_settings)
-
-    def _get_ldap(self):
+    @property
+    def ldap(self):
         if self._ldap is None:
             options = getattr(django.conf.settings, 'AUTH_LDAP_GLOBAL_OPTIONS', None)
 
             self._ldap = _LDAPConfig.get_ldap(options)
 
         return self._ldap
-    ldap = property(_get_ldap)
 
     def get_user_model(self):
         """
@@ -169,9 +145,9 @@ class LDAPBackend(object):
     def authenticate(self, request=None, username=None, password=None, **kwargs):
         if bool(password) or self.settings.PERMIT_EMPTY_PASSWORD:
             ldap_user = _LDAPUser(self, username=username.strip())
-            user = ldap_user.authenticate(password)
+            user = self.authenticate_ldap_user(ldap_user, password)
         else:
-            logger.debug('Rejecting empty password for %s' % username)
+            logger.debug('Rejecting empty password for {}'.format(username))
             user = None
 
         return user
@@ -204,10 +180,12 @@ class LDAPBackend(object):
         if not hasattr(user, 'ldap_user') and self.settings.AUTHORIZE_ALL_USERS:
             _LDAPUser(self, user=user)  # This sets user.ldap_user
 
-        if hasattr(user, 'ldap_user') and (user.ldap_user.dn is not None):
-            return user.ldap_user.get_group_permissions()
+        if hasattr(user, 'ldap_user'):
+            permissions = user.ldap_user.get_group_permissions()
         else:
-            return set()
+            permissions = set()
+
+        return permissions
 
     #
     # Bonus API: populate the Django user from LDAP without authenticating.
@@ -223,14 +201,68 @@ class LDAPBackend(object):
     # Hooks for subclasses
     #
 
+    def authenticate_ldap_user(self, ldap_user, password):
+        """
+        Returns an authenticated Django user or None.
+        """
+        return ldap_user.authenticate(password)
+
+    def get_or_build_user(self, username, ldap_user):
+        """
+        This must return a (User, built) 2-tuple for the given LDAP user.
+
+        username is the Django-friendly username of the user. ldap_user.dn is
+        the user's DN and ldap_user.attrs contains all of their LDAP
+        attributes.
+
+        The returned User object may be an unsaved model instance.
+
+        """
+        if self.__class__.get_or_create_user != LDAPBackend.get_or_create_user:
+            # Older deprecated method overridden, defer to it instead.
+            warnings.warn(
+                "Method LDAPBacked.get_or_create_user() is deprecated and will "
+                "be removed in a future version. Override "
+                "LDAPBacked.get_or_build_user() instead. "
+                "LDAPBacked.get_or_build_user() does not need to save newly "
+                "built users.",
+                DeprecationWarning,
+            )
+            return self.get_or_create_user(username, ldap_user)
+
+        model = self.get_user_model()
+
+        if self.settings.USER_QUERY_FIELD:
+            query_field = self.settings.USER_QUERY_FIELD
+            query_value = ldap_user.attrs[self.settings.USER_ATTR_MAP[query_field]][0]
+            lookup = query_field
+        else:
+            query_field = model.USERNAME_FIELD
+            query_value = username.lower()
+            lookup = '{}__iexact'.format(query_field)
+
+        try:
+            user = model.objects.get(**{lookup: query_value})
+        except model.DoesNotExist:
+            user = model(**{query_field: query_value})
+            built = True
+        else:
+            built = False
+
+        return (user, built)
+
     def get_or_create_user(self, username, ldap_user):
         """
         This must return a (User, created) 2-tuple for the given LDAP user.
         username is the Django-friendly username of the user. ldap_user.dn is
-        the user's DN and ldap_user.attrs contains all of their LDAP attributes.
+        the user's DN and ldap_user.attrs contains all of their LDAP
+        attributes.
+
+        Deprecated, but remains for backwards compatibility. Remove in a future
+        release.
         """
         model = self.get_user_model()
-        username_field = getattr(model, 'USERNAME_FIELD', 'username')
+        username_field = model.USERNAME_FIELD
 
         kwargs = {
             username_field + '__iexact': username,
... 3110 lines suppressed ...

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/django-auth-ldap.git



More information about the Python-modules-commits mailing list