Repository navigation
Description
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
- install OC server & an LDAP server (e.g. OpenLDAP)
- login to OC server as a user via web interface
- 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
PaulHughes99 commentedon Sep 14, 2016
I've checked previous working configuration Owncloud 9.0.0.19 ; this appears like a major bug in LDAP in the new version.
[-]LDAP over-authenticating after upgrade[/-][+]LDAP over-authenticating after upgrade UPDATED/Simplified[/+]PVince81 commentedon Oct 6, 2016
@owncloud/ldap
PVince81 commentedon Oct 6, 2016
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.
PaulHughes99 commentedon Oct 6, 2016
Thanks for your response - happy to assist with any test to nail this issue.
PVince81 commentedon Oct 20, 2016
Maybe we need a config switch, also on the LDAP wizard, to disable such checks...
@jvillafanez what do you think ?
PVince81 commentedon Nov 9, 2016
You could try to increase the value from
60 * 5to3600 * 24to have the check only done once a day: https://github.com/owncloud/core/blob/v9.1.2/lib/private/User/Session.php#L571Then 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.
jvillafanez commentedon Nov 17, 2016
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.
42 remaining items
PVince81 commentedon Jul 13, 2017
@felixboehm already fixed in #28252 by @cornelinux.
But looking at the code it seems to be missing a way to turn the check of completely: https://github.com/owncloud/core/pull/28269/files#diff-9c47cee6ac987e5256aeee509f91ddb1R611.
cornelinux commentedon Jul 13, 2017
@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!
PaulHughes99 commentedon Jul 13, 2017
fredreichbier commentedon Jul 13, 2017
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
$loginResultin LoginController.php:204 beingnull. This is because$useris the name provided by the user (e.g.user333), but theoc_accountstable only seems to store UUIDs in the case of the user_ldap backend.However, I replaced
with
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
setLastCheckfix from above, we are down to one LDAP bind request per login, which is great! :)PVince81 commentedon Jul 13, 2017
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
fredreichbier commentedon Jul 13, 2017
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?)
PVince81 commentedon Jul 13, 2017
@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.
fredreichbier commentedon Jul 13, 2017
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
masterbranch of ownCloud and user_ldap, the situation is the following:masterwe 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 :)
PVince81 commentedon Jul 13, 2017
@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.
PVince81 commentedon Jul 19, 2017
Closing this now.
@fredreichbier when ready, please raise separate issue/PR and link them here. Thanks.
fredreichbier commentedon Jul 22, 2017
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!
PVince81 commentedon Jul 24, 2017
@fredreichbier thanks a lot!
lock commentedon Aug 2, 2019
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.