Issue
- When an unauthenticated user tries to access a resource URL (e.g., a direct link to a PDF served by a portlet), they are not redirected to the login page.
- This behavior is observed for URLs that contain the
p_p_lifecycle=2parameter, which corresponds to the Resource Serving Phase of the portlet lifecycle. - We would like the user to be redirected to the login page and, after successful authentication, be redirected back to the originally requested resource.
Environment
- Liferay DXP 7.0+
Resolution
This is the expected behavior of the platform and is compliant with the Java Portlet Specification 2.0 (JSR 286).
- When a URL includes the
p_p_lifecycle=2parameter, it initiates the Resource Serving Phase. In this phase, the client (e.g., a web browser) is specifically requesting a resource, such as a file or JSON data, not an HTML page. - According to the portlet standard, the response must be the resource itself. Responding with a redirect to a login page (which is an HTML document, typically with an HTTP 200 or 302 status) would violate the specification for this lifecycle phase.
- Therefore, Liferay cannot automatically redirect unauthenticated users to the login page for these types of resource requests.