Fórumok

How to share user info to other domain ?

thumbnail
Anil T, módosítva 9 év-val korábban

How to share user info to other domain ?

Expert Bejegyzések: 313 Csatlakozás dátuma: 2012.01.14. Legújabb bejegyzések
Hi,

I have requirement to share user login/guest information to other domain which is not implemented on Liferay platform. So can we set from liferay some parameters and get from other domain ? Any suggestions ?

Thanks,
Anil T
thumbnail
Samuel Kong, módosítva 9 év-val korábban

RE: How to share user info to other domain ?

Liferay Legend Bejegyzések: 1902 Csatlakozás dátuma: 2008.03.10. Legújabb bejegyzések
thumbnail
Stian Sigvartsen, módosítva 9 év-val korábban

RE: How to share user info to other domain ?

Regular Member Bejegyzések: 103 Csatlakozás dátuma: 2010.08.27. Legújabb bejegyzések
If you're crossing domains then you need to be aware of the Same Origin Policy that browsers implement which will in most cases prevent you from successfully calling the Liferay JSON webservices. A way to get around this is to use JSONP, a generic non-Liferay related example is here.

As far as I know Liferay 6.1+ doesn't support JSONP out of the box, but all you need to do is create a ServletFilter hook or a delegate servlet which reverse proxies the Liferay JSON URLs and makes the following changes to the response:

  • Change the response Content-Type header to "application/javascript"
  • Prefix the response body with a Javascript function call. for example "callback(" (omitting the quotation marks)
  • Suffix the response content with a closing bracket for the JavaScript function all. i.e. " ) " (omitting the quotation marks)


If you're experienced with manipulating OutputStreams via servlet filters then you could actually wrap Liferay's OutputStream and achieve the above that way too.

Your non-Liferay website would need to implement the callback() function which will receive a JSON object as parameter.

Hope this helps.

-Stian