Fórum

set user role based on IP

thumbnail
Markus Krause, modificado 10 Anos atrás.

set user role based on IP

New Member Postagens: 13 Data de Entrada: 14/08/12 Postagens Recentes
Hi Liferay Experts,

we have a website based on Liferay 6.1 which uses several roles, e.g. guest (not logged in), user (loggged in), it staff (logged in, member of group "it staff") and so on.
The guest role should only see something like "welcome, please login" which works but we want to show our local user which are coming from the private IP range 10.x to see some more things, e.g. address book portlet.
How can I assign a role to a (lot-logged-in user) based on his IP (range)?
I know I can get the users IP by the method getRemoteAdd() in the request but how do get this tested on every request the user is sending (means every access request to the website)? Can this be done by a hook or is this better done by a servlet filter? (e.g. like described in http://connect-sam.com/2012/06/creating-servlet-filter-hook-in-liferay-6-1-to-restrict-access-based-on-ip-location/ but for geolocation)?
If a servlet filter is the right way to go how can i set the role of the user?

thanks advance to any hints!

best regards,
markus