question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

getsentry-ldap-auth not works with django-auth-ldap 1.2.14+

See original GitHub issue

How to reproduce:

  • Install latest Sentry and getsentry-ldap-auth (with django-auth-ldap 1.2.14 or later)
  • Configure LDAP authentification
  • Login to the Sentry via LDAP user
  • Logout from the Sentry
  • Login again with the same user

Expected result

  • You should successfully login second time

Actual result

  • “Wrong username or password” error

Logs

First, successful login:

05:01:30 [DEBUG] django_auth_ldap: search_s('ou=users,dc=orgz', 2, '(uid=%(user)s)') returned 1 objects: uid=a.markelov,ou=users,dc=orgz
05:01:30 [DEBUG] django_auth_ldap: search_s('ou=users,dc=orgz', 2, '(uid=%(user)s)') returned 1 objects: uid=a.markelov,ou=users,dc=orgz
05:01:30 [DEBUG] django_auth_ldap: Populating Django user a.markelov
05:01:30 [DEBUG] django_auth_ldap: Populating Django user a.markelov
05:01:30 [INFO] sentry.auth: user.auth.success (username=u'a.markelov' ip_address=u'178.218.107.255')

Second, unsucsessful login:

172.18.0.1 - - [06/Oct/2017:05:01:35 +0000] "GET /auth/login/ HTTP/1.0" 200 10783 "https://sentry.unitedtraders.work" "Go-http-client/1.1"
05:01:41 [DEBUG] django_auth_ldap: search_s('uid=a.markelov,ou=users,dc=orgz', 0, '(objectClass=*)') returned 0 objects: 
05:01:41 [DEBUG] django_auth_ldap: search_s('uid=a.markelov,ou=users,dc=orgz', 0, '(objectClass=*)') returned 0 objects: 
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/site-packages/django_auth_ldap/backend.py", line 350, in authenticate
    self._get_or_create_user()
  File "/usr/local/lib/python2.7/site-packages/django_auth_ldap/backend.py", line 577, in _get_or_create_user
    self._user, created = self.backend.get_or_create_user(username, self)
  File "/usr/local/lib/python2.7/site-packages/sentry_ldap_auth/backend.py", line 38, in get_or_create_user
    if 'mail' in ldap_user.attrs:
TypeError: argument of type 'NoneType' is not iterable
05:01:41 [ERROR] django_auth_ldap: Caught Exception while authenticating a.markelov
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/site-packages/django_auth_ldap/backend.py", line 350, in authenticate
    self._get_or_create_user()
  File "/usr/local/lib/python2.7/site-packages/django_auth_ldap/backend.py", line 577, in _get_or_create_user
    self._user, created = self.backend.get_or_create_user(username, self)
  File "/usr/local/lib/python2.7/site-packages/sentry_ldap_auth/backend.py", line 38, in get_or_create_user
    if 'mail' in ldap_user.attrs:
TypeError: argument of type 'NoneType' is not iterable
05:01:41 [ERROR] django_auth_ldap: Caught Exception while authenticating a.markelov

This behavior exists with django-auth-ldap 1.2.14, 1.2.15, 1.2.16. I think this is related to Under search/bind mode, the user's DN will now be cached for performance (https://bitbucket.org/psagers/django-auth-ldap/src/569b6ca46ce8a27af2b6d712caea09b2ed6c894e/CHANGES?at=default&fileviewer=file-view-default#CHANGES-41).

As a workaround, I suggest to pin django-auth-ldap requirement.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
rakshazicommented, Nov 24, 2017
0reactions
barronhagermancommented, Dec 4, 2017

I have pinned the version of django-auth-ldap to 1.2.* because there is a problem installing sentry-ldap-auth with django-auth-ldap 1.3. However, everything seems to work fine for me with django-auth-ldap 1.2.16.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Django Authentication Using LDAP — django-auth-ldap 4.1.1 ...
This is a Django authentication backend that authenticates against an LDAP service. Configuration can be as simple as a single distinguished name template,...
Read more >
django-auth-ldap 4.1.0
This is a Django authentication backend that authenticates against an LDAP service. Configuration can be as simple as a single distinguished name template, ......
Read more >
Cannot auth ldap user by django-auth-ldap
I´m having problems getting ldap users authenticated with django-auth-ldap 1.2.8. I can log-in by use of Apache Directory Studio as followed ...
Read more >
Problem getting django_auth_ldap up and running
I'm attempting to setup django_auth_ldap against an openldap server and am not ... http://packages.python.org/django-auth-ldap/#example-configuration and
Read more >
Devilry Documentation
There was a bug where filtering did not work if an imported tag and ... Authenticating via LDAP requires the django-auth-ldap Python module ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found