User impersonation - how to

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
Report Content as Inappropriate

User impersonation - how to

Krzysztof Watral
This post was updated on .

Currently we have two possibilities (which I know) to impersonate some account as a different user.

# First solution can be implemented in the following way:
Map<String, Object> authenticationInfo = Maps.newHashMap();
authenticationInfo.put(ResourceResolverFactory.USER_IMPERSONATION, userId);
resourceResolver = resourceResolverFactory.getServiceResourceResolver(authenticationInfo);
it works, but adds a lot of effort for Administrators, because they have to define each user in list of possible impersonators (unfortunately this approach doesn't support a group of users).

# Second approach is to get user session using SlingRepository.impersonateFroService:
slingRepository.impersonateFromService(null, credentials, null);
Unfortunately, this requires to pass userId and password, that is usually impossible to get from programmatical point of view.

To make life easier, it would be nice if one of the following suggestion would be implemented:
 - slingRepository.impersonateFromService(null, credentials, null); could start accepting userId (without passing password)
 - impersonators could be configured for group of users

Let me know If there is any other solution