Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
RE: Impersonating friendly URLs
I am trying to pass doAsUserId param to my friendly URL .../attachment/2749384?doAsUserId=xRdO8Wv72X5YHWlYGO, but it is apparently not passed upstream.
When my route is processed and enters the serveResource() method, the user retrieved from resourceRequest is not that impersonated user, but real one.
Is there any workaround for this?
When my route is processed and enters the serveResource() method, the user retrieved from resourceRequest is not that impersonated user, but real one.
<route>
<pattern>/attachment/{attachmentId:[^/]+}</pattern>
<implicit-parameter name="p_p_lifecycle">2</implicit-parameter>
<implicit-parameter name="p_p_cacheability">cacheLevelPage</implicit-parameter>
<implicit-parameter name="mvcPath">/attachment.jsp</implicit-parameter>
</route>
This prevents to emulate some functionality from that specific user perspective. Is there any workaround for this?
Jan Tošovský:
I probably can't help you directly, but it might help to mention the exact Liferay version. And if there's a newer GA on your major version, try if it's an issue that was already fixed.
I am trying to pass doAsUserId param to my friendly URL
Hi Olaf, a good point. I checked this in old 6.2 version and it works as expected there. Now I am on 7.2 GA1. So this seems to be a regression. I'll test this on some core friendly URLs if it is really global issue or just a problem of my portlet.
Jan Tošovský, modified 5 Years ago.
RE: Impersonating friendly URLs
(Answer)
Liferay Master
Posts: 576
Join Date: 7/22/10
Recent Posts
I fixed it. Originally this was fix for another issue, but both turned out to be related.
My resourceAction should return PNG attachment, but the content was written directly to the page as characters. After further analysis I found this binary content is wrapped by senna container so I finally found the root cause.
My links look like this: <a href=" .../attachment/2749384?doAsUserId=xRdO8Wv72X5YHWlYGO">. However, they are internally processed by SennaJS, which, in my case, breaks the original functionality.
So with the help of https://stackoverflow.com/questions/41288039/how-can-i-disable-sennajs-spa-in-liferay-7 I changed the link to <a href=" .../attachment/2749384?doAsUserId=xRdO8Wv72X5YHWlYGO" data-senna-off="true">
It not only fixed that attachment issue, but also impersonating one.
My resourceAction should return PNG attachment, but the content was written directly to the page as characters. After further analysis I found this binary content is wrapped by senna container so I finally found the root cause.
My links look like this: <a href=" .../attachment/2749384?doAsUserId=xRdO8Wv72X5YHWlYGO">. However, they are internally processed by SennaJS, which, in my case, breaks the original functionality.
So with the help of https://stackoverflow.com/questions/41288039/how-can-i-disable-sennajs-spa-in-liferay-7 I changed the link to <a href=" .../attachment/2749384?doAsUserId=xRdO8Wv72X5YHWlYGO" data-senna-off="true">
It not only fixed that attachment issue, but also impersonating one.
Copyright © 2025 Liferay, Inc
• Privacy Policy
Powered by Liferay™