etianen/django-python3-ldap

Allow other kwargs in ldap.authenticate

stinovlas opened this issue · 3 comments

Function django_python3_ldap.ldap.authenticate checks whether it receives all attributes listed in settings.LDAP_AUTH_USER_LOOKUP_FIELDS. However, it also checks that there are no other arguments which causes problems when we use multiple django authentication backends. I suggest to replace != with not >=:

-    if not password or frozenset(kwargs.keys()) != frozenset(settings.LDAP_AUTH_USER_LOOKUP_FIELDS):
+    if not password or not frozenset(kwargs.keys()) >= frozenset(settings.LDAP_AUTH_USER_LOOKUP_FIELDS):

The proposed change is backwards compatible.

If you agree, I can submit a merge request =o).

I submitted PR #227. It was actually a bit more complicated than my suggestion above, but not by much.