[API] New GroupManager component

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[API] New GroupManager component

Thomas Mortagne
Administrator
Hi devs,

I just introduced a new GroupManager API (and related script service
and new modules).

The idea (for now) is just to provide two new clean entry points to:
* get the members of a group
* get the groups of a member

Right, yet another one but here is what's new:

* it's a component
* you can use it without depending on oldcore
* it support groups of groups
* there is a cache behind the scene for all that

Main Java entry point:
https://github.com/xwiki/xwiki-platform/blob/master/xwiki-platform-core/xwiki-platform-user/xwiki-platform-user-api/src/main/java/org/xwiki/user/group/GroupManager.java
Script service ($services.user.group):
https://github.com/xwiki/xwiki-platform/blob/master/xwiki-platform-core/xwiki-platform-user/xwiki-platform-user-script/src/main/java/org/xwiki/user/script/GroupScriptService.java

Also to start actually using it I added in the profile a new section
which display all the groups (including groups of groups) the user
belongs to.

I also needed the feature in a 8.4.5 wiki so I published a contrib
extension you can use before 10.8:
https://extensions.xwiki.org/xwiki/bin/view/Extension/User%20membership%20in%20the%20profile/
(this is the application but the API is available too, look at the
application dependencies).

TODO:
* remove the cache from group service and recommend using the new
component instead (the new component is still based on the group
service since people might implement this service another way so it's
safer to keep going trough the configured service for now, also it's
not that based to separate caching and groups of groups handling from
storage anyway)
* track down all uses of the group service and the old rightmanager
plugin group membership related methods and replace them with the new
API

FUTURE:
The module name is xwiki-platform-user-api and there is a (empty
except from the sub script service bridge) user script service, the
idea being that we will want to add other user related APIs there in
the future but I did not had time to work on the big picture so I left
room for it.

Thanks,
--
Thomas Mortagne
Reply | Threaded
Open this post in threaded view
|

Re: [API] New GroupManager component

Denis Gervalle-2
Hi Thomas,

Congrats, that’s a long awaited API, we will enjoy it.

> * track down all uses of the group service and the old rightmanager
> plugin group membership related methods and replace them with the new
> API

Be aware that the bridge of the security module is accessing group membership using the group service, and it has it’s own caching mechanism. Since it is listening to the same even as your cache, it could not be based on it. So be careful not to make it use any method that is using the cache.

Good job, thanks.

--
Denis Gervalle
SOFTEC sa - CEO
On 6 Sep 2018, 09:53 +0200, Thomas Mortagne <[hidden email]>, wrote:

> Hi devs,
>
> I just introduced a new GroupManager API (and related script service
> and new modules).
>
> The idea (for now) is just to provide two new clean entry points to:
> * get the members of a group
> * get the groups of a member
>
> Right, yet another one but here is what's new:
>
> * it's a component
> * you can use it without depending on oldcore
> * it support groups of groups
> * there is a cache behind the scene for all that
>
> Main Java entry point:
> https://github.com/xwiki/xwiki-platform/blob/master/xwiki-platform-core/xwiki-platform-user/xwiki-platform-user-api/src/main/java/org/xwiki/user/group/GroupManager.java
> Script service ($services.user.group):
> https://github.com/xwiki/xwiki-platform/blob/master/xwiki-platform-core/xwiki-platform-user/xwiki-platform-user-script/src/main/java/org/xwiki/user/script/GroupScriptService.java
>
> Also to start actually using it I added in the profile a new section
> which display all the groups (including groups of groups) the user
> belongs to.
>
> I also needed the feature in a 8.4.5 wiki so I published a contrib
> extension you can use before 10.8:
> https://extensions.xwiki.org/xwiki/bin/view/Extension/User%20membership%20in%20the%20profile/
> (this is the application but the API is available too, look at the
> application dependencies).
>
> TODO:
> * remove the cache from group service and recommend using the new
> component instead (the new component is still based on the group
> service since people might implement this service another way so it's
> safer to keep going trough the configured service for now, also it's
> not that based to separate caching and groups of groups handling from
> storage anyway)
> * track down all uses of the group service and the old rightmanager
> plugin group membership related methods and replace them with the new
> API
>
> FUTURE:
> The module name is xwiki-platform-user-api and there is a (empty
> except from the sub script service bridge) user script service, the
> idea being that we will want to add other user related APIs there in
> the future but I did not had time to work on the big picture so I left
> room for it.
>
> Thanks,
> --
> Thomas Mortagne
Reply | Threaded
Open this post in threaded view
|

Re: [API] New GroupManager component

Thomas Mortagne
Administrator
On Thu, Sep 6, 2018 at 10:15 AM Denis Gervalle <[hidden email]> wrote:

>
> Hi Thomas,
>
> Congrats, that’s a long awaited API, we will enjoy it.
>
> > * track down all uses of the group service and the old rightmanager
> > plugin group membership related methods and replace them with the new
> > API
>
> Be aware that the bridge of the security module is accessing group membership using the group service, and it has it’s own caching mechanism. Since it is listening to the same even as your cache, it could not be based on it. So be careful not to make it use any method that is using the cache.

Yes I don't plan to modify the security module right now since it has
its own special cache which mix rights and membership.

To be clear for others the "rightmanager plugin" I'm referring to is a
very old plugin located on
https://github.com/xwiki/xwiki-platform/tree/master/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/plugin/rightsmanager.

>
> Good job, thanks.
>
> --
> Denis Gervalle
> SOFTEC sa - CEO
> On 6 Sep 2018, 09:53 +0200, Thomas Mortagne <[hidden email]>, wrote:
> > Hi devs,
> >
> > I just introduced a new GroupManager API (and related script service
> > and new modules).
> >
> > The idea (for now) is just to provide two new clean entry points to:
> > * get the members of a group
> > * get the groups of a member
> >
> > Right, yet another one but here is what's new:
> >
> > * it's a component
> > * you can use it without depending on oldcore
> > * it support groups of groups
> > * there is a cache behind the scene for all that
> >
> > Main Java entry point:
> > https://github.com/xwiki/xwiki-platform/blob/master/xwiki-platform-core/xwiki-platform-user/xwiki-platform-user-api/src/main/java/org/xwiki/user/group/GroupManager.java
> > Script service ($services.user.group):
> > https://github.com/xwiki/xwiki-platform/blob/master/xwiki-platform-core/xwiki-platform-user/xwiki-platform-user-script/src/main/java/org/xwiki/user/script/GroupScriptService.java
> >
> > Also to start actually using it I added in the profile a new section
> > which display all the groups (including groups of groups) the user
> > belongs to.
> >
> > I also needed the feature in a 8.4.5 wiki so I published a contrib
> > extension you can use before 10.8:
> > https://extensions.xwiki.org/xwiki/bin/view/Extension/User%20membership%20in%20the%20profile/
> > (this is the application but the API is available too, look at the
> > application dependencies).
> >
> > TODO:
> > * remove the cache from group service and recommend using the new
> > component instead (the new component is still based on the group
> > service since people might implement this service another way so it's
> > safer to keep going trough the configured service for now, also it's
> > not that based to separate caching and groups of groups handling from
> > storage anyway)
> > * track down all uses of the group service and the old rightmanager
> > plugin group membership related methods and replace them with the new
> > API
> >
> > FUTURE:
> > The module name is xwiki-platform-user-api and there is a (empty
> > except from the sub script service bridge) user script service, the
> > idea being that we will want to add other user related APIs there in
> > the future but I did not had time to work on the big picture so I left
> > room for it.
> >
> > Thanks,
> > --
> > Thomas Mortagne



--
Thomas Mortagne