Skip to content
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

[Ldap] Improve the LDAP component #16665

Closed
5 tasks
csarrazi opened this issue Nov 25, 2015 · 15 comments
Closed
5 tasks

[Ldap] Improve the LDAP component #16665

csarrazi opened this issue Nov 25, 2015 · 15 comments

Comments

@csarrazi
Copy link
Contributor

A few issues are remaining, and will likely need to be fixed after release 3.0 (3.1 or later):

Here is the list of issues which were mentioned in #14602:

  • Add a way to configure all ldap_set_option entries.
    • Dereferencing
    • Timeout
    • Debug level
    • ...
  • Handle multiple connections

I'm separating all these from the current PR (#15994), as I am currently the only person working on the LDAP component on a regular basis, and won't have time to handle these remaining features for Symfony's 2.8 / 3.0 releases.

@cilefen
Copy link
Contributor

cilefen commented Dec 2, 2015

@csarrazi Thank you so much for the time you have put into this. In implementing this in 2.8, we have found that authentication is limited to only users whose DNs fit the configured dn_string, for example:

dn_string: "uid={username},ou=people,dc=example,dc=com"

A user with "uid=foo,ou=something,ou=people,dc=example,dc=com" cannot authenticate.

The immediate reason is that after discovering information from ldap in the ->find() method, the DN is discarded when LdapUserProvider::loadUser() creates the User instance.

Because the DN is discarded, later LdapBindAuthenticationProvider::checkAuthentication() recombines the basic username with what is configured in dn_string:

$dn = str_replace('{username}', $username, $this->dnString);

It would seem if User were extended to store the DN, it would not be necessary to set dn_string, and users in various OU's could authenticate.

@csarrazi
Copy link
Contributor Author

csarrazi commented Dec 2, 2015

Hum, could you be a bit more precise regarding your configuration. Are you using the Ldap user provider along with the http_basic_ldap authentication provider?

@ChadSikorra
Copy link
Contributor

Also (unless I'm overlooking something), the LDAP component currently uses the ldap_escape function in the client, which is only available in PHP 5.6. But the PHP requirement for the component is 5.3?

@nicolas-grekas
Copy link
Member

nicolas-grekas commented Dec 3, 2015 via email

@ChadSikorra
Copy link
Contributor

Ah, then I did overlook something hah (: Thanks. That's the same function I've seen in a SO answer. I do notice that it doesn't encode carriage returns properly when escaping DNs. I've mentioned it in the comments on SO where it's posted too, but I don't think I ever got a response.

Huge edge case I guess (who in their right mind puts a carriage return in a DN..), but it's listed in the RFC.

@nicolas-grekas
Copy link
Member

Can you please open an issue on the symfony-polyfill? And if you have a patch, PR is welcomed :-)

@csarrazi
Copy link
Contributor Author

csarrazi commented Dec 3, 2015

Regarding the carriage return, we should add a test case in both the PHP extension, and in symfony/polyfill (as the test cases are taken from the PHP extension).

@cilefen
Copy link
Contributor

cilefen commented Dec 3, 2015

@csarrazi If you want me to open a new issue, say the word. Here is the configuration:

security:
    providers:
        in_memory:
            memory: ~
        app_users:
            ldap:
                service: app.ldap
                base_dn: %ldap.base_dn%
                search_dn: null
                search_password: null
                filter: (uid={username})
                default_roles: ROLE_USER
    firewalls:
        secure:
            provider:  app_users
            stateless: true
            pattern:   ^/secure
            http_basic_ldap:
                service: app.ldap
                dn_string: "uid={username},ou=people,dc=example,dc=com"
        dev:
            pattern: ^/(_(profiler|wdt)|css|images|js)/
            security: false
        main:
            anonymous: ~

@csarrazi
Copy link
Contributor Author

csarrazi commented Dec 3, 2015

Should be in a new issue, but this feedback is great regardless! :)

@cilefen
Copy link
Contributor

cilefen commented Dec 3, 2015

#16823

@ChadSikorra
Copy link
Contributor

@csarrazi The version of LDAP escape in polyfill actually already does more than the official version of ldap_escape. The one in polyfill handles leading/trailing spaces in a DN (which is correct, per the RFC), whereas the official version of the function does not.

I can submit a PR with new tests and also account for the carriage return. But should that carriage return be handled properly in the polyfill function if the official ldap_escape doesn't handle it properly? Or should the polyfill version be left alone to behave exactly like the PHP version and the additional encoding be handled elsewhere until the PHP version is fixed?

@nicolas-grekas
Copy link
Member

nicolas-grekas commented Dec 3, 2015 via email

@ChadSikorra
Copy link
Contributor

Submitted the polyfill fix here: symfony/polyfill#14 .

@xabbuh xabbuh added the Ldap label Dec 10, 2015
@Xeyos88
Copy link

Xeyos88 commented Jan 12, 2016

This is a complete example also with authentication form? Why I can not authenticate.
Before I make a bind anonymous and should then perform the bind for the form but not function.

@csarrazi
Copy link
Contributor Author

@Xeyos88 The documentation will be updated as soon as the component will be marked as stable, which should be good for 3.1. Until then, as mentioned in the subtree split, the component is still a work in progress.

fabpot added a commit that referenced this issue Feb 18, 2016
This PR was merged into the 3.1-dev branch.

Discussion
----------

[Ldap] Fixed CS and hardened some code

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #16665
| License       | MIT
| Doc PR        | no

This PR takes into account remaining comments from #16665

Commits
-------

eefa70d Fixed CS and hardened some code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants