RE: How to create ServletFilter for url-pattern '/'

Jamie Sammons, modified 2 Years ago. New Member Posts: 23 Join Date: 2/27/12 Recent Posts
Hi,
i am running on 7.4.3.48-ga48 . I wanted to create a servlet filter in a hook, but it is not called at all.
I have the following filter definition inside the liferay-hook.xml:
    <servlet-filter>
        <servlet-filter-name>Some Filter</servlet-filter-name>
        <servlet-filter-impl>at.....SomeFilter</servlet-filter-impl>
    </servlet-filter>
	<servlet-filter-mapping>
        <servlet-filter-name>Some Filter</servlet-filter-name>
        <url-pattern>/</url-pattern>
    </servlet-filter-mapping>
 
It seems that the url-pattern '/' is not accepted. What can i do, that the servlet filter is invoked on the root path? Is there a different approach possible?
 
Thank you in advance,
Philipp
thumbnail
Jamie Sammons, modified 2 Years ago. Liferay Legend Posts: 14933 Join Date: 9/2/06 Recent Posts

We don't use filters/hooks anymore.

Now we use OSGi.

Search the portal source looking for implementations of javax.servlet.Filter and you'll find examples how to do it.

Note though that "/" as a url pattern isn't going to get you far because Liferay automatically redirects to appropriate places.

Can you share what you need to do? I might be able to offer a better solution...

Jamie Sammons, modified 2 Years ago. New Member Posts: 23 Join Date: 2/27/12 Recent Posts

Hi,

thanks for the response.

 

Actually i am trying to evaluate GET parameters that are passed to the "/" path.

In case they are available and valid, then i store them into the session for later use.
​​​​​​In case they are available and invalid, i want to return a specifc HTTP error code.

The base idea behind is, to launch a PKCE authentication workflow.
This worked in Liferay 6, but I have troubles to get this running in Liferay 7
​​​

thumbnail
Jamie Sammons, modified 2 Years ago. Liferay Legend Posts: 14933 Join Date: 9/2/06 Recent Posts

Liferay 7 already has support for OAuth2 and PKCE authentication flows.

Perhaps your whole customization for Liferay 6 is now moot and you can exclude it completely?