-
Notifications
You must be signed in to change notification settings - Fork 104
Unbind ldap connection after authentication #174
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
I ran into an issue where my ldap server was flooded with tons of opened connection that would only close when I restarted my web server. I traced it down to django-auth-library authentication, which does not properly unbind after retrieving what it needs on the server. This fix should help with scalability for people having the same issue ("Too many open files..." error message).
Also ensure that the populate_user request is properly unbind
This is an important issue. Otherwise, my LDAP server won't react to any new connection requests and users stop being able to login into the server |
Can you please investigate the test failures and add a new one? |
Sorry for the long silence. I looked into the test failure and I believe it's related to this issue within python-ldap: python-ldap/python-ldap#253 |
I believe tests expect to be able to reuse the connection from the LDAP user, but this change unbinds it. From https://www.python-ldap.org/en/python-ldap-3.3.0/reference/ldap.html#ldap.LDAPObject.unbind_s:
For example, django-auth-ldap/tests/tests.py Lines 720 to 722 in 2758cdb
The test failures indicate this change is preventing future loading of user properties (such as group membership) from the The way to go is to improve the current design of maintaining a (lazy) connection per IIUC, LDAP can repeatedly bind as different users. An idea could be to pool LDAP connections, and have all call sites perform a bind before executing their request. Currently, depending on configuration, the library can bind once to execute the search for the user, a second time with the user credentials (to authenticate the user) and a third time to load the user attributes. |
I (believe I) was having this issue, with django-auth-ldap getting SERVER_DOWN back from the server after logging in several users, and then preventing further login for a time period. I have implemented this change by subclassing the LDAPBackend and unbinding the ldap connection within that (to save having a separate branch of the LDAPBackend). However, I agree a reused connection pool would be a nicer solution. |
I ran into an issue where my ldap server was flooded with tons of open connections that would only close when I restart my web server. I traced it down to django-auth-library authentication & populate_user method, which does not properly unbind after retrieving what it needs on the server.
This fix should help with scalability for people having the same issue ("Too many open files..." error message).