Skip to content

LDAP over-authenticating after upgrade UPDATED/Simplified #26065

Closed

Description

@PaulHughes99

After upgrading OC Server (from 9.0.0.19 to 9.1.0.15) , a previously working LDAP setup is broken; LDAP is now making at least three authentication calls (binds with user password) each time a client logs in through webinterface, and frequent unwanted authentications from the desktop client (previously it was only one authentication when the client booted up).
(NB This matters because I've successfully implemented 2-factor authentication onto the LDAP server, so too many authentications causes total chaos) This is a very severe issue.
My question is whether the LDAP coding in OC has changed; and is there way to prevent these multiple authentications?
I've noted topic: https://central.owncloud.org/t/lot-of-ldap-traffic/19091 which may have similar cause.
This is my first post , so apologies if i've not provided some relevant info.

Steps to reproduce

  1. install OC server & an LDAP server (e.g. OpenLDAP)
  2. login to OC server as a user via web interface
  3. check log of LDAP server to see multiple bindings for single login. (Not sure how to see that on OC's own log)

Expected behaviour

OC should perform a single authentication on LOGIN, and thereafter cache shoudl prevent further authentications being necessary; the OC desktop client should authenticate only once at startup.

The LDAP log from working Owncloud 9.0 server (grep -R slapd /var/log/syslog) shows a single search for the user's UID -- in this case 'ttest' followed within the same connection by a successful bind with the full DN 'test test' etc, and password.

SRCH base="dc=so*********_" scope=2 deref=0 filter="(&(|(objectClass=inetOrgPerson))(|(uid=ttest)(|(?mailPrimaryAddress=ttest)(mail=ttest))))"
...
BIND dn="cn=test test',ou=users,dc=so**_******_" method=128
BIND dn="cn=test test',ou=users,dc=so**_*******" mech=SIMPLE ssf=0

###Actual behaviour

in OC 9.1, the LDAP server is being asked to search THREE times for the user name, and the username plus password is authenticated THREE times.

 _(search1)_
SRCH base="dc=so******_**t" scope=2 deref=0 filter="(&(|(objectClass=inetOrgPerson))(uid__=ttest)__)"
 ...
BIND dn="cn=__test test__,ou=users,dc=so_*****_**t" method=128
BIND dn="cn=__test test__,ou=users,dc=so_*******_t" mech=SIMPLE ssf=0
 ..

_(search2)_
SRCH base="dc=so**_***_**t" scope=2 deref=0 filter="(&(|(objectClass=inetOrgPerson))(uid=__ttest__))"
 ..
BIND dn="cn=__test test__,ou=users,dc=so_*****_**t" method=128
BIND dn="cn__=test test,__ou=users,dc=so_********t" mech=SIMPLE ssf=0

_(search3)_
SRCH base="dc=so******_**t" scope=2 deref=0 filter="(&(|(objectClass=inetOrgPerson))(uid=__ttest)_*)"
 ..
BIND dn="cn=**test test**,ou=users,dc=so******_**t" method=128
BIND dn="cn=__test test__,ou=users,dc=so_********t" mech=SIMPLE ssf=0

Server configuration

Operating system: Ubuntu
Web server: Apache/2.4.7 (Ubuntu)
Database: MySQL
PHP version: PHP 5.5.9-1ubuntu4.19 (cli) (built: Jul 28 2016 19:31:33)
ownCloud version (see ownCloud admin page): ownCloud 9.1.0 (stable)
Updated from an older ownCloud or fresh install: updated
ownCloud log (data/owncloud.log, see https://central.owncloud.org/t/how-to-find-webserver-or-oc-logfile-enable-php-logfile/808):

Special configuration (external storage, external authentication, reverse proxy, server-side-encryption):

Integrity status for oC9+

Login as admin user into your ownCloud and access
http://example.com/index.php/settings/integrity/failed
paste the results here.
No errors have been found.

{
    "system": {
        "updatechecker": false,
        "instanceid": "oci9*****",
        "passwordsalt": "***REMOVED SENSITIVE VALUE***",
        "secret": "***REMOVED SENSITIVE VALUE***",
        "trusted_domains": [
            "****",
            "****t"
        ],
        "datadirectory": "\/var\/www\/owncloud\/data",
        "overwrite.cli.url": "http:\/\/****\/owncloud",
        "dbtype": "sqlite3",
        "version": "9.1.0.15",
        "logtimezone": "UTC",
        "installed": true,
        "ldapIgnoreNamingRules": false,
        "mail_smtpmode": "smtp",
        "mail_from_address": "***",
        "mail_domain": "****",
        "mail_smtpauthtype": "LOGIN",
        "mail_smtphost": "smtp.***.com",
        "mail_smtpport": "**",
        "mail_smtpauth": 1,
        "mail_smtpname": "***REMOVED SENSITIVE VALUE***",
        "mail_smtppassword": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpsecure": "ssl",
        "loglevel": 0,
        "maintenance": false
    }
}

LDAP configuration (delete this part if not used)


+-------------------------------+---------------------------------------------------------------------------------------+
| Configuration                 |                                                                                       |
+-------------------------------+---------------------------------------------------------------------------------------+
| hasMemberOfFilterSupport      |                                                                                       |
| hasPagedResultSupport         |                                                                                       |
| homeFolderNamingRule          |                                                                                       |
| lastJpegPhotoLookup           | 0                                                                                     |
| ldapAgentName                 | uid=user******\*                                                                      |
| ldapAgentPassword             | **\*                                                                                  |
| ldapAttributesForGroupSearch  |                                                                                       |
| ldapAttributesForUserSearch   |                                                                                       |
| ldapBackupHost                |                                                                                       |
| ldapBackupPort                |                                                                                       |
| ldapBase                      | dc=so******\*                                                                         |
| ldapBaseGroups                | dc=so******\*                                                                         |
| ldapBaseUsers                 | dc=so******\*                                                                         |
| ldapCacheTTL                  | 600                                                                                   |
| ldapConfigurationActive       | 1                                                                                     |
| ldapDynamicGroupMemberURL     |                                                                                       |
| ldapEmailAttribute            | mail                                                                                  |
| ldapExperiencedAdmin          | 0                                                                                     |
| ldapExpertUUIDGroupAttr       |                                                                                       |
| ldapExpertUUIDUserAttr        |                                                                                       |
| ldapExpertUsernameAttr        |                                                                                       |
| ldapGroupDisplayName          | cn                                                                                    |
| ldapGroupFilter               |                                                                                       |
| ldapGroupFilterGroups         |                                                                                       |
| ldapGroupFilterMode           | 0                                                                                     |
| ldapGroupFilterObjectclass    |                                                                                       |
| ldapGroupMemberAssocAttr      | uniqueMember                                                                          |
| ldapHost                      | 127.0.0.1                                                                             |
| ldapIgnoreNamingRules         |                                                                                       |
| ldapLoginFilter               | (&(|(objectclass=inetOrgPerson))(|(uid=%uid)(|(mailPrimaryAddress=%uid)(mail=%uid)))) |
| ldapLoginFilterAttributes     |                                                                                       |
| ldapLoginFilterEmail          | 1                                                                                     |
| ldapLoginFilterMode           | 0                                                                                     |
| ldapLoginFilterUsername       | 1                                                                                     |
| ldapNestedGroups              | 0                                                                                     |
| ldapOverrideMainServer        |                                                                                       |
| ldapPagingSize                | 500                                                                                   |
| ldapPort                      | 389                                                                                   |
| ldapQuotaAttribute            |                                                                                       |
| ldapQuotaDefault              |                                                                                       |
| ldapTLS                       | 0                                                                                     |
| ldapUserDisplayName           | cn                                                                                    |
| ldapUserDisplayName2          |                                                                                       |
| ldapUserFilter                | (|(objectclass=inetOrgPerson))                                                        |
| ldapUserFilterGroups          |                                                                                       |
| ldapUserFilterMode            | 0                                                                                     |
| ldapUserFilterObjectclass     | inetOrgPerson                                                                         |
| ldapUuidGroupAttribute        | auto                                                                                  |
| ldapUuidUserAttribute         | auto                                                                                  |
| turnOffCertCheck              | 0                                                                                     |
| useMemberOfToDetectMembership | 1                                                                                     |
+-------------------------------+---------------------------------------------------------------------------------------+

Activity

  1. PaulHughes99 commented on Sep 14, 2016

    @PaulHughes99
    Author

    I've checked previous working configuration Owncloud 9.0.0.19 ; this appears like a major bug in LDAP in the new version.

  2. changed the title [-]LDAP over-authenticating after upgrade[/-] [+]LDAP over-authenticating after upgrade UPDATED/Simplified[/+] on Sep 16, 2016
  3. PVince81 commented on Oct 6, 2016

    @PVince81
    Contributor

    @owncloud/ldap

  4. PVince81 commented on Oct 6, 2016

    @PVince81
    Contributor

    Since 9.1 there is some new logic that will try and detect whether a LDAP user still exists by doing a bind with the user password. Maybe that check is running too early and causes additional needless calls.

  5. added this to the 9.1.2 milestone on Oct 6, 2016
  6. PaulHughes99 commented on Oct 6, 2016

    @PaulHughes99
    Author

    Thanks for your response - happy to assist with any test to nail this issue.

  7. PVince81 commented on Oct 20, 2016

    @PVince81
    Contributor

    Maybe we need a config switch, also on the LDAP wizard, to disable such checks...

    @jvillafanez what do you think ?

  8. modified the milestones: 9.1.3, 9.1.2 on Oct 20, 2016
  9. PVince81 commented on Nov 9, 2016

    @PVince81
    Contributor

    You could try to increase the value from 60 * 5 to 3600 * 24 to have the check only done once a day: https://github.com/owncloud/core/blob/v9.1.2/lib/private/User/Session.php#L571

    Then see if it help reduce the over-authentication.

    We should make that value configurable and if the value is "0" or "-1", disable the check altogether.

  10. jvillafanez commented on Nov 17, 2016

    @jvillafanez
    Member

    The only code piece that could be over-authenticating in the LDAP code should be https://github.com/owncloud/core/blob/stable9.1/apps/user_ldap/lib/User_LDAP.php#L137 . Probably core is checking too many times the password.

  11. 42 remaining items

  12. PVince81 commented on Jul 13, 2017

    @PVince81
    Contributor
  13. cornelinux commented on Jul 13, 2017

    @cornelinux
    Contributor

    @PVince81 @felixboehm
    For me it was ok, to not turn the check of completely.
    I would simply set this to 8 hours or 24 hours. After all for me this is important for OTP authentication. And I am happy, if the user needs to enter a one time password once a day!

  14. PaulHughes99 commented on Jul 13, 2017

    @PaulHughes99
    Author
  15. fredreichbier commented on Jul 13, 2017

    @fredreichbier
    Contributor

    Thank you for looking into this @PVince81 @felixboehm! My backtraces above actually came from an installation of ownCloud 10.0.2, so the issue is still prevalent in ownCloud 10.

    However, I just tried the current ownCloud master and user_ldap master. First, I had the problem that I couldn't log in at all using the user_ldap app due to a HTTP 500. This was caused by $loginResult in LoginController.php:204 being null. This is because $user is the name provided by the user (e.g. user333), but the oc_accounts table only seems to store UUIDs in the case of the user_ldap backend.
    However, I replaced

    $loginResult = $this->userManager->get($user);

    with

    $loginResult = $this->userSession->getUser();

    which allows me to log in just fine. Do you think that change is sensible? I can also do a PR, if you prefer that.

    And indeed, this eliminates request 2 from above. In conjunction with the setLastCheck fix from above, we are down to one LDAP bind request per login, which is great! :)

  16. PVince81 commented on Jul 13, 2017

    @PVince81
    Contributor

    Cool, so do we agree to close this ticket ?

    @fredreichbier if you are having other problems with LDAP latest versions, please raise a new ticket in https://github.com/owncloud/user_ldap

  17. fredreichbier commented on Jul 13, 2017

    @fredreichbier
    Contributor

    Yes, I think if we can get the two one-line fixes merged into master, this ticket can be closed. Thanks!

    Should I do two PRs? (since the first fix only removes the bind request 3, whereas the second fix seems necessary to get user_ldap running on the current master in general?)

  18. PVince81 commented on Jul 13, 2017

    @PVince81
    Contributor

    @fredreichbier hmm I'm not really following what you mean. What PRs or fixes are you talking about ?

    I'm only aware of the fix from #28252 which is already on master and stable10.

  19. fredreichbier commented on Jul 13, 2017

    @fredreichbier
    Contributor

    Sorry if I didn't make this clear enough. The situation is the following:

    On ownCloud 10.0.2, we still see three LDAP bind requests per login (see my backtraces here). The fix from #28252 only fixes the issue that the bind request 3 is repeated every five minutes.

    On the master branch of ownCloud and user_ldap, the situation is the following:

    • We cannot login at all using the user_ldap backend because each login with correct credentials results in a HTTP 500. The one-line change I mention here seems to fix this. However, I have no idea if this is a user_ldap or a core issue :)
    • With this fix applied on master we can log in using the user_ldap backend again. Also, bind request 2 is gone (thanks to 9ffca34 I think), but ownCloud still sends two bind requests (i.e. requests 1 and 3 from above) per login. We can eliminate bind request 3 by setting the initial lastCheckTime of each token to the current time (by adding $dbToken->setLastCheck($this->time->getTime()); here).

    So, all in all, applying these two fixes to master reduces the number of bind requests per login from 3 to 1. Please let me know if anything is unclear :)

  20. PVince81 commented on Jul 13, 2017

    @PVince81
    Contributor

    @fredreichbier ok thanks. Please raise the issue about 500 in the user_ldap repo and/or submit your one-liner as PR. Whether this belongs to core and user_ldap, maybe @jvillafanez can help with that. But let's discuss this separate issue there.

  21. PVince81 commented on Jul 19, 2017

    @PVince81
    Contributor

    Closing this now.

    @fredreichbier when ready, please raise separate issue/PR and link them here. Thanks.

  22. fredreichbier commented on Jul 22, 2017

    @fredreichbier
    Contributor

    Just a heads-up: I opened two issues (#28449 and #28467) and two pull requests (#28450 and #28468). With both PRs applied on master, it seems like one login request then corresponds to one Bind Request :)
    Thank you for your help!

  23. PVince81 commented on Jul 24, 2017

    @PVince81
    Contributor

    @fredreichbier thanks a lot!

  24. lock commented on Aug 2, 2019

    @lock

    This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

  25. locked as resolved and limited conversation to collaborators on Aug 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type:Bugp1-urgentregression

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions