-
Notifications
You must be signed in to change notification settings - Fork 104
Feature bind template #311
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
Thanks for the PR and rationale. Can you give a bit more details about why you would like to avoid to configuring a bind user? |
I see your point, but IMHO any user credentials (in this case the bind user) which do not need to be saved in plain text in any config file, can not be lost are leaked by accident. And since configuring LDAP is not really easy I would not wonder if admins actually use the admin/root user as the bind user (which even might have access to read the password hash!). And in some companies it might not be "easy" to actually get a bind user from the AD admins. On the other side, I do not see a reason why an admin would want to hide from a user, to which groups he belongs (or other details of his LDAP entry e.g. email/phone number). So the user should be able to "find" his/her groups he/she belongs to (even if they are nested). Also a bind user might be "misconfigured", but I agree that would be easier to debug. I consider django_auth-ldap as a framework, which gives admins the power to do things in a way they want it to do. With power comes responsibility. And you never can save all admins from mistakes :) And the option to not use a bind user is already given, this PR only add more possibilities to make use of that "feature". So what do you think, does the PR have a chance? |
This PR has a chance. I agree that the library should not block users from having their ways of doing things, unless they are obviously shooting themselves in the foot, which does not seem to be the case here. I probably would fight pretty hard to get a “system” user that binds and executes the searches on my projects, but that’s only my perspective. Because your use case is not easy to fill with the library, changing the library is fine. There are issues with the proposed approach:
Ideally, the tests would reuse (and maybe extend) the existing logic to setup the LDAP rather that use a different setup. |
OK thx, then I will continue, but I will not have time to work on it during July. I will continue in August on it.
Yeah I was wondering the same already earlier but back then it looked simpler to introduce the
So yeah I need some check there, when
Yeah one part uses the same LDAP, but I spent some 4-5h to try to get the already running LDAP to change the config on the fly to not allow anonymous bindings, without success. The other part is the same more or less copy/pasted. With the tests I still have some ideas how to refactor. I will also tackle that once we agreed on the use on |
This is a WIP PR so not everything is polished yet, e.g. PEP8 (too long lines) fail at the moment also the documentation is not yet updated. Also the test classes could be streamlined and duplicated code avoided. But it is easier to handle things with these long lines for the moment and I wanted to make it first work and pass. Still I would like to get some feedback already.
The motivation for this PR is a issue which I ran into and is related to issue (#173) (actually might even solve it). Our ActiveDirectory does not allow anonymous binding and I want to avoid to configure a bind user. I can't just use the user template (
USER_DN_TEMPLATE
), since the structure is not really flat. So I have to search for users. So I want to use theBIND_AS_AUTHENTICATING_USER
setting. So that the user binds himself but the real dn is still searched. But unfortunately to bind to the AD LDAP only providing thesAMAccountName
is not sufficient, it needs to be sAMAccountName@AD.DOMIAN. So I came up with theBIND_DN_TEMPLATE
config option which can be used for that.I added some tests to check the current behavior (bfc5365) and changed the
connection
property (current state is in some 4 commits):django-auth-ldap/django_auth_ldap/backend.py
Lines 464 to 470 in 24cc547
And updated some of the testcases that now work (work in the sense that this config options get a user)
With these changes I can now configure the following and Django can authenticate users and find their groups without bind user:
I also added a coverage target to tox.ini, to verify that from my new code all is covered.
Maybe also #301 should be taken into account, but I didn't verify that yet.