Search code examples
jsfprimefacescorsliferayweb-application-firewall

PrimeFaces in a WAF environent, internal and external URLs


Say we have an internal URL https://my.internal.url (in our case a Liferay Portal) and from a web application firewall an external URL https://my.external.url pointing to this internal URL.

The internet user is using the external URL.

PrimeFaces extends attributes like for example

onclick="...;window.open('https://my.interal.url'..."

This leads to CORS problems.

The HTTP header Access-Control-Allow-Origin is not an option, since the internal URL is internal.

We'll talk with the WAF people about URL replacement, but I'd like to know wether or not we can tell PrimeFaces to use the external URL (or maybe relative URLs in case this would work).

The portal doesn't know about the external URL but of course we could implement this as a configuration option.

(watching the source code, there are more occurences of the internal URL outside of the jsf/PrimeFaces portlet, so I add the liferay tag too)

Update

The question is obsolete, WAF has to handle this correctly (an old SSL environment did it, a new WAF environment doesn't)


Solution

  • You say

    The portal doesn't know about the external URL

    however, any properly configured reverse proxy (or WAF) should forward the actual host name used to request the current page.

    On Apache httpd's mod_proxy_http, this is done with the option ProxyPreserveHost On. When forwarding with AJP, the host is automatically forwarded. Other WAF/Proxy configurations - of course - differ. But the proper way to generate the URL is to let the generating server know what URLs it should generate.

    If you need to worry about the proper host name, you'll need to do so by request: Liferay is well able to use Virtual Host names to distinguish between different sites - and if they're completely different, you might be signed in to one of them, but not to the other. This has a repercussion on the permissions.

    Have the infrastructure handle it for you. Don't write code (or application configuration) for it.