At work, we've inherited this Java class which handles all SSO login operations. There's a FiltroSegurancaGlobal.class which is mapped to *, forcing everything with a annotation
@WebFilter(urlPatterns = { "/*" })
The class is deployed in a JAR with a few other classes to handle the whole SSO operation.
Recently I was requested to install and configure a git server for internal purposes, I found a really interesting solution GitBlit, which works like a charm.
Here's the thing, when I deployed it to the server somehow some requests are slipping through the filter. That seemed impossible so I changed the filter to nothing:
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException, ServletException {
System.out.println("filter hit");
}
While the whole application wasn't being loaded, the user wasn't being redirected to the log in page, none of the resources (css,js) were loaded, but the (index) still shows in the developer tools windows with some of the page.
How is this possible? Wasn't a deployed filter with "/*" urlPatterns supposed to filter ALL requests?
As mentioned bellow I tried changing the urlPatters using annotation first, then server's web.xml later:
@WebFilter({"/", "*", "/*"})
and then
<filter-mapping>
<filter-name>FiltroSegurancaGlobal</filter-name>
<url-pattern>/*</url-pattern>
<url-pattern>*</url-pattern>
<url-pattern>/</url-pattern>
</filter-mapping>
Nothing has changed.
By probing chrome I realized that the only file that seemed to come through the server was angular.js, by searching their github I found a NgController.java file which has an odd code segment:
public void renderHead(IHeaderResponse response) {
// add Google AngularJS reference
response.renderJavascriptReference(new ResourceReference(NgController.class, "angular.js"));
The actual class also implements IHeaderContributor, which is from the Apache Wicket package, not sure if this helps to troubleshoot the issue.
I also found this question which mentions FORWARD requests, I'm gonna try checking this out, but I'm still not sure what's going on.
Just a minor addition, it seems that the correct solution would be using Tomcat's Valve but that question has a comment mentioning that: [Filters]'re only overridable whenever webapp's /WEB-INF/web.xml has another one with same filter name.
Which is an impossible situation in this case, since I doubt the deployed app has a filter map with the same filter name.
I'll probably migrate the whole thing to the Valve Component to make sure it's server wide, but I still don't understand what's going on in this particular scenario.
ALSO: I forgot to mention that GitBlit has a console output when a user tries to connect, ex: 2016-05-13 13:53:38 [INFO ] 0 repositories identified with calculated folder sizes in 5 msecs
and I just noticed that the filter hit system.out.println is being executed AFTER it, meaning somehow the request from the browser is not passing through it.