Vista combinada Visión Plana Vista de árbol
Discusiones [ Anterior | Siguiente ]
toggle
Ingemar Jansson
[SOLVED] Setting session attribute in auto login hook
16 de junio de 2010 1:42
Respuesta

Ingemar Jansson

Ranking: New Member

Mensajes: 4

Fecha de incorporación: 23 de mayo de 2010

Mensajes recientes

Hi

I have set an attribute in the HttpSession in an auto login hook.
Then I set the request attribute AutoLogin.AUTO_LOGIN_REDIRECT.

When I try to get the attribute from the session it's not there.

I see in the code that there is a redirect when AutoLogin.AUTO_LOGIN_REDIRECT attribute is set but I thought the JSESSIONID cookie should keep the same session even after a redirect.

Is it not possible to set a session attribute in an auto login hook and fetch it from the page I'm redirecting to?

Regards
Ingemar
Thomas Berg
RE: Setting session attribute in auto login hook
15 de junio de 2010 23:35
Respuesta

Thomas Berg

Ranking: Regular Member

Mensajes: 125

Fecha de incorporación: 7 de septiembre de 2009

Mensajes recientes

Hej Ingemar,

It's possible, check these settings in portal(-ext).properties:

 1##
 2## Request
 3##
 4
 5    #
 6    # Portlets that have been configured to use private request attributes in
 7    # liferay-portlet.xml may still want to share some request attributes. This
 8    # property allows you to configure which request attributes will be shared.
 9    # Set a comma delimited list of attribute names that will be shared when the
10    # attribute name starts with one of the specified attribute names. For
11    # example, if you set the value to "hello_,world_", then all attribute names
12    # that start with "hello_" or "world_" will be shared.
13    #
14    request.shared.attributes=LIFERAY_SHARED_
15
16##
17## Session
18##
19
20    #
21    # Portlets that have been configured to use private session attributes in
22    # liferay-portlet.xml may still want to share some session attributes. This
23    # property allows you to configure which session attributes will be shared.
24    # Set a comma delimited list of attribute names that will be shared when the
25    # attribute name starts with one of the specified attribute names. For
26    # example, if you set the value to "hello_,world_", then all attribute names
27    # that start with "hello_" or "world_" will be shared.
28    #
29    # Note that this property is used to specify the sharing of session
30    # attributes from the portal to the portlet. This is not used to specify
31    # session sharing between portlet WARs or from the portlet to the portal.
32    #
33    session.shared.attributes=org.apache.struts.action.LOCALE,COMPANY_,USER_,LIFERAY_SHARED_


HTH

Thomas
Ingemar Jansson
RE: Setting session attribute in auto login hook
16 de junio de 2010 1:42
Respuesta

Ingemar Jansson

Ranking: New Member

Mensajes: 4

Fecha de incorporación: 23 de mayo de 2010

Mensajes recientes

Hej Thomas

Thank you.

Regards
Ingemar
Gary Pinkham
RE: [SOLVED] Setting session attribute in auto login hook
5 de agosto de 2010 5:59
Respuesta

Gary Pinkham

Ranking: New Member

Mensajes: 17

Fecha de incorporación: 30 de julio de 2010

Mensajes recientes

Ingemar Jansson:

I have set an attribute in the HttpSession in an auto login hook.


Curious.. Is Auto Login Hook the same as "Custom Authentication"? as described here: Developing a custom authentication system

I can't seem to figure out how to get access to the HttpSession from within the Authenticator..

Thanks!
Gary
Davy Kamerbeek
RE: Setting session attribute in auto login hook
15 de noviembre de 2012 11:46
Respuesta

Davy Kamerbeek

Ranking: New Member

Mensajes: 23

Fecha de incorporación: 12 de marzo de 2012

Mensajes recientes

I'm having the same issue.. Can somebody give some pointers?
Davy Kamerbeek
RE: Setting session attribute in auto login hook
17 de noviembre de 2012 0:47
Respuesta

Davy Kamerbeek

Ranking: New Member

Mensajes: 23

Fecha de incorporación: 12 de marzo de 2012

Mensajes recientes

Ok, figured it out. The autologin has it's own HttpSession. When the user is logged in a new HttpSession is created.

So when you want to set some http session objects, you must set those objects after the autologin. So use a custom PostLoginAction that does that.
vincent alfandari
RE: Setting session attribute in auto login hook
13 de marzo de 2014 8:37
Respuesta

vincent alfandari

Ranking: New Member

Mensajes: 6

Fecha de incorporación: 22 de mayo de 2012

Mensajes recientes

If you need to retrieve a variable such as a token SSO you can do this :
- In the hook AutoLogin set a request parameter :
1
2request.setParameter("tokenSSO", tokenSSO)

- Add a hook at event "login.events.post" that retrieve the request parameter and put it in the session
1
2String tokenSSO = request.getParameter("tokenSSO")
3request.getSession().addAttribute("tokenSSO", tokenSSO)