discourse-ldap-auth icon indicating copy to clipboard operation
discourse-ldap-auth copied to clipboard

Add groups from LDAP

Open g5pw opened this issue 9 years ago • 14 comments
trafficstars

It would be nice to have a group sync between LDAP and Discourse, i.e. when creating a new user on Discourse, assign it to the Discourse groups matching the groups on LDAP. What would be the best way to do this?

g5pw avatar Nov 06 '16 15:11 g5pw

If you are using the list user create mode, you can specify groups in your ldap_user.yml and they will automatically be populated on user creation. Currently, the plugin does not support assigning Discourse groups directly from LDAP Groups.

jonmbake avatar Nov 08 '16 12:11 jonmbake

Currently, the plugin does not support assigning Discourse groups directly from LDAP Groups.

Is this something you thought about doing or could be contributed? I'm not really well versed in ruby but I could give it a go.

g5pw avatar Dec 11 '16 19:12 g5pw

Should all groups sync? What if the group doesn't exist in Discourse? Can you give your example use case for this feature? ie. What types of LDAP groups you want to sync with Discourse.

jonmbake avatar Dec 12 '16 18:12 jonmbake

IMO only already existing groups should sync (on Discourse-side). Or it could do what it does for users, user choice between:

  • Create groups
  • Create groups only in whitelist
  • Don't create groups (assign only)

You could probably specify a root DN under which all groups are, and/or a LDAP filter.

g5pw avatar Jan 15 '17 11:01 g5pw

I'm also not really well verse in ruby, but if someone could give me a rough outline I could try out a PR as well. Looking at the code it wasn't clear how to get omniauth to return the groups so the plugin has access in the LDAPUser constructor or the auth_result function.

wburningham avatar May 08 '17 17:05 wburningham

@wburningham From my recollection, what is passed back from omniauth is fixed. You can see what is returned by "putting" the auth_info in either plugin.rb or LDAPUser, e.g. put auth_info, which should print to the log.

jonmbake avatar May 10 '17 01:05 jonmbake

This would be a very useful feature! My thoughts on how it could work are as follows:

  • Manually specify a mapping of "group name" : "LDAP group" for allowed groups
  • When a user logs in their LDAP login is checked against each of the specified LDAP groups and if they're a member of that LDAP group they're added to the corresponding discourse group and if they're not a member of that group they're removed from the corresponding discourse group.

That would enable the group membership to stay in-sync with the LDAP groups. If that would slow down the login too much the group membership check could just be done at account creation time with a "cleanup task" which could be run periodically to keep things in-sync

dhirschfeld avatar Jul 16 '17 23:07 dhirschfeld

Did something happen in this case in the past 6 months?

rotecodefraktion avatar Mar 10 '18 14:03 rotecodefraktion

Looks like there is an outstanding PR in omniauth-ldap that is necessary in order to implement this change: Add options to retrieve LDAP group membership.

jonmbake avatar Mar 11 '18 01:03 jonmbake

Unfortunately, this would require a code change to a dependent library so there is not much we can do. We could remove the dependency on omniauth-ldap and use something else, but I think the risk outweighs the benefits. Let me know if you guys have any other ideas.

jonmbake avatar Mar 11 '18 02:03 jonmbake

Is there a update of the progress available?

sbernhard avatar Oct 04 '19 15:10 sbernhard

We have moved to discourse-saml in the mean time, so our interest waned. :(

g5pw avatar Oct 04 '19 15:10 g5pw

We have successfully implemented it in discourse-ldap-auth, but currently it still requires a forked version of omniauth-ldap. I have tried to contact the maintainers, but the project doesn't really seem to be active anymore.

ghost avatar Mar 03 '22 13:03 ghost

Thank you for doing this! It's exactly what I've been seeking for years. Any information on which fork or how to apply it?

tareko avatar Apr 06 '22 12:04 tareko