core icon indicating copy to clipboard operation
core copied to clipboard

8.1 - LDAP: Having memberOf enabled breaks nested groups

Open GreenArchon opened this issue 11 years ago • 15 comments

Steps to reproduce

  1. Have an LDAP server, with memberOf enabled
  2. Have owncloud configured for said LDAP server, with "Nested groups" enabled in the "advanced settings"
  3. Put LDAP user u1 in LDAP group g2
  4. Put LDAP group g2 in LDAP group g1

Expected behaviour

Owncloud should see the user u1 as a member of g1 (as well as g2)

Actual behaviour

Owncloud only sees the user u1 as a member of g2

Server configuration

Operating system: CentOS 7 ownCloud version: 8.1 Are you using an external user-backend, if yes which one: LDAP LDAP Server OpenLDAP

A bit of debugging...

090478a95e1adc904cd8971158c848b9c00374f6 added a speedup to the apps/user_ldap/group_ldap.php' getUserGroups() function, by using the memberOf attribute if possible (instead of checking all groups to see if the user's there, recursively if the nested groups option is enabled in the settings). However, memberOf itself is not recursive, thus nested groups are missed.

The code checks for memberOf support as well as the config option 'useMemberOfToDetectMembership', however, the said option is not exposed anywhere in the user interface...

I'd provide a PR but I'm unsure what would be the best solution between adding an option in the settings and not using memberOf if nested groups are enabled (or some third option I didn't think of)

@blizzz Thoughts, since you wrote that code?

GreenArchon avatar Jul 20 '15 18:07 GreenArchon

@blizzz

karlitschek avatar Jul 22 '15 02:07 karlitschek

@GreenArchon is it reproducable when you disable useMemberOfToDetectMembership (only via occ, setting to 0)?

blizzz avatar Jul 24 '15 12:07 blizzz

Setting it to 0 fixes the issue, I've run it that way for the past 2 weeks without problems.

GreenArchon avatar Jul 24 '15 14:07 GreenArchon

@GreenArchon thanks for the update.

Since nested groups don't work with memberOf, as you say (and which is a pity), there is probably no way around to also take the "nested groups" options into account (in the same statement as useMemberOfToDetectMembership is).

Or, do we find memberOf information in the groups? Then we might think of a way to utilize it.

@GreenArchon If you like (I'd appreciate it) you can look whether 2nd is possible without too many changes to be backportable, or to open a PR with extended the if-clause, or both (with the first solution to backport and - if bigger changes - an improved behaviour for 8.2). Do you?

blizzz avatar Jul 24 '15 18:07 blizzz

@blizzz memberOf seems to be in groups too, at least it's what I'm seeing on OpenLDAP, and it's what I understand from reading the overlay's doc: "The memberof overlay updates an attribute (by default memberOf) whenever changes occur to the membership attribute (by default member) of entries of the objectclass (by default groupOfNames) configured to trigger updates." (www.openldap.org/doc/admin24/overlays.html, section 12.8.1). So there's nothing restricting the classes getting the memberOf attribute.

So we could indeed simply recursively check the memberOf attributes of the different groups if nesting is enabled (a bit like how getGroupsByMember() does). I can try to cook a PR for that soon, as I think it would be the best solution, unless you have an objection.

GreenArchon avatar Jul 24 '15 19:07 GreenArchon

That sounds like the best option, since reading entries is always faster than searching through big directory branches. Would be awesome if you look into it.

blizzz avatar Jul 24 '15 20:07 blizzz

Alright, free time was a bit more scarce than anticipated, sorry for the delay. Quick notes:

  • This is not the best code I've written, as there's now 3 different functions in group_ldap that basically do the same thing (find elements based on attributes of a certain type on a DN), but they don't exactly return the same thing, and I didn't want to get into that for a quick bugfix (I should open a separate issue I guess)
  • I had to quick fix the unit tests since more LDAP calls are now necessary since we nest properly.

GreenArchon avatar Aug 04 '15 03:08 GreenArchon

It doesn't work for me in 8.2.RC1. Maybe someone can give a try in order to see if something has been broken in 8.2 or if it is due to my conf. (WFM 8.1.stable)

davitol avatar Oct 13 '15 15:10 davitol

You could retry with the branch from back then when it worked: https://github.com/owncloud/core/pull/18042#issuecomment-136377306 But the branch might be deleted, so jump to the commit on master: a55f233e9ffac7d492733f50a37343b4243898bf (you'll need to resetup from scratch)

If that commit works on your current env but the latest master (or 8.2RC2) doesn't, then there's a regression.

PVince81 avatar Oct 14 '15 07:10 PVince81

@davitol to try based on https://github.com/owncloud/core/issues/17759#issuecomment-147964323 . If that doesn't work, move to 8.2.1

ghost avatar Oct 14 '15 12:10 ghost

jump to the commit on master: a55f233

Tested again and WFM with this commit

davitol avatar Oct 15 '15 08:10 davitol

Ok, so this means it worked there and got broken again on master / 8.2RC2 ?

PVince81 avatar Oct 15 '15 08:10 PVince81

If that commit works on your current env but the latest master (or 8.2RC2) doesn't, then there's a regression.

Can we then have a separate ticket for the regression. It isn't related to the 8.1.x releases.

MorrisJobke avatar Oct 15 '15 08:10 MorrisJobke

Bisection results:

There are only 'skip'ped commits left to test. The first bad commit could be any of: 845485cfe637c3a7fdb72a110cb68c769b2f8d4b 9d03b7c6b7131761f29f79e6c33473b0ca483856 002b6bf059377853dc174c1d49792e62983c4bec We cannot bisect more!

Thanks @PVince81 for the 'git lesson' :hatched_chick:

davitol avatar Oct 15 '15 09:10 davitol

Raised 8.2 regression here https://github.com/owncloud/core/issues/19816

PVince81 avatar Oct 15 '15 14:10 PVince81