Adding servlet filter to CAS server

52 views
Skip to first unread message

Mark van Rossum

unread,
May 21, 2021, 1:08:48 PM5/21/21
to CAS Community
Hi,

Following on from my previous message about CAS throwing an NPE when a service specifies renew=true, I'm trying to write a Servlet Filter to remove this parameter from an incoming request before it gets to CAS.

I've written a filter and put it in "src/main/java/..../StripRenewFilter.java", then tried adding the filter to the web.xml file as:
  <filter>
    <filter-name>StripRenewFilter</filter-name>
    <filter-class>uk.ac.bris.adt.StripRenewFilter</filter-class>
  </filter>

  <filter-mapping>
    <filter-name>StripRenewFilter</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping>

But it doesn't take effect.  I've also tried annotating the filter with @WebFilter which equally had no effect.

I'm running CAS locally using "gradlew run"

How can I load a filter into a CAS server to achieve this?

Thank you!
Mark van Rossum

Julio Romero

unread,
Aug 11, 2022, 11:56:04 PM8/11/22
to CAS Community, Mark van Rossum
Hello Mark,

I know it's probably way to late for a reply, but I came across a similar issue.
It looks like you have almost everything good to go, the only thing you're missing is declaring your custom servlet in the META-INF/spring.factories file, like below:

org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
com.example.CustomConfig1,\
com.example.CustomConfig2,\ 
uk.ac.bris.adt.StripRenewFilter



Regards,
Julio
Reply all
Reply to author
Forward
0 new messages