-
-
Notifications
You must be signed in to change notification settings - Fork 650
fix/ldap_anonymous_bind #2831
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
fix/ldap_anonymous_bind #2831
Conversation
@tpw56j Could you somehow add tests so this doesn't happen again? |
Codecov Report
@@ Coverage Diff @@
## master #2831 +/- ##
==========================================
+ Coverage 43.44% 43.92% +0.47%
==========================================
Files 99 99
Lines 14258 14301 +43
==========================================
+ Hits 6195 6281 +86
+ Misses 8063 8020 -43
Continue to review full report at Codecov.
|
@SchoolGuy I will try to write additional tests for the parameters in this PR. |
@tpw56j Thanks a lot! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I needed an ldap connect and used this code as reference code.
So I can confirm that the code works (I even could try an anonymous and non-anonymous connect) and that the patch is correct.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@SchoolGuy To test authentication via ldap, we need an ldap server. 389-ds is available in all supported distributions. Can we include it in the docker image for testing? |
@tpw56j Yes please do so. I had my hopes up for openLDAP but whatever works is fine. Those images are for testing, so size does not matter. |
@SchoolGuy I was also hoping that it would be possible to use openLDAP, but found that RedHat stopped supporting it and removed openLDAP from its repos. I myself use openLDAP and have never used 389-ds before, so it will take me a while to figure out how to test with 389-ds in different distros. |
@tpw56j I would prefer you get started with openLDAP then on Debian and/or openSUSE. I believe that our code should be not that different for authentication on the different distros. At least that would be my proposal. |
@SchoolGuy OpenLDAP is not available only in CentOS 8. With openLDAP it will be easier for me to start, and with CentOS it will be possible to figure it out later. Therefore, I agree that I will need to start with openLDAP. |
@tpw56j The tests are all currently failing. Is this because you forgot to add & start the LDAP Server or is this not yet finished? |
@SchoolGuy I haven't added openldap to the docker image yet, so this error is expected. I will continue to work with this PR. It was a surprise for me that for a long time I could not pass a negative test for establishing a TLS connection until I understood the difference between ldaps and starttls and that in these cases different objects should be used to set TLS parameters. All code examples I could find as well as in authentication/ldap.py used the ldap object to set TLS options. At first glance, this code looks correct, but in reality, certificates are not checked and only create the illusion of security. Maybe add to cobbler the ability to set other TLS parameters from python-ldap? At least OPT_X_TLS_REQUIRE_CERT, OPT_X_TLS_CIPHER_SUITE, OPT_X_TLS_CRLCHECK seem important enough to me. |
@tpw56j Okay let's do the following. You add the tests. We accept that they are failing because we know that we have a bug. Then at the same time we open a bug for this and anyone who has the time opens a followup PR for this. I see this as a separate matter from what you are trying to do with this PR. |
If you have a better way to do it then I am open for suggestions! |
@SchoolGuy Maybe I will include the necessary packages in the docker image of at least one distro and we will get a passing test in it? Fedora requires openldap-servers, openldap-clients, python3-ldap, sscg.
|
The only missing thing is not the supervisorctl config for slapd: I found this:
You need to put that in the right directory and then you should be fine. |
@SchoolGuy Thanks! I will try to do this. |
@SchoolGuy I was unable to add openldap to the Fedora34 container this way. And I couldn't find a way to select this container for testing. |
We do the testing on GitHub with the openSUSE Tumbleweed container built in the openSUSE Buildservice here. I will take care of the submission on OBS side once you have added all required things to the Dockerfile here in Git. For local testing we use the same dockerfile and thus you can build that container yourself like described in the Wikipage "Testing". To select the Fedora 34 container locally for testing (sadly only one-shot possible which makes it really slow) you need the |
@tpw56j You are aware that https://pypi.org/project/ldap/ is a placeholder which we do not want probably? Or is this an intended change? |
@SchoolGuy cobbler/modules/authentication/ldap.py does not use ldap3, so I replaced ldap3 with ldap everywhere. I will remove https://pypi.org/project/ldap. |
@tpw56j Oh that sounds like a lot of tech-debt. Do you need help with something or should I just monitor your progress and review? |
@SchoolGuy Thanks for your willingness to help, I'll try to finish the ldap-related code changes myself. |
@SchoolGuy My branch is missing Debian 11, so I cannot make changes there. And in system-test there is an error not related to my changes (dhcpd). |
@tpw56j You could rebase the branch on Edit: I see you have that but it is failing... |
So building works fine but installing does not. Does Debian 11 not have the required packages? |
@SchoolGuy Debian 11 requires the python3-ldap package, as does Debian 10. I will try to rebase and modify there. |
df5bc8d
to
04631e1
Compare
@SchoolGuy The rebase seems to have been successful. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM even with the new changes!
@tpw56j Is this fully ready in your eyes? |
@SchoolGuy So far I don't like this added code:
I think I figured out how to change it in this PR and I'll try to do it. And we also do not have a mechanism for validating a fixed list of supported values in the settings, such as, for example, ldap_tls_reqcert or default_template_type, default_virt_type. But this change would probably be better done in a separate PR. |
@tpw56j Thanks a lot for the status update! Take your time and don't feel rushed! |
@SchoolGuy PR is ready to review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
System-Tests are broken currently but this is not the concern of this PR. Since we have new tests which cover most/some of the new code and this was previously untested, I will accept the new PR. Thanks for your work @tpw56j !
Inversion of the ldap_anonymous_bind value