My application is running on Websphere application server 9.0.0.9. I have the following security constraints added in the web.xml file of my application. The intention is to secure every request irrespective of whether it needs to be authenticated or not.
<security-constraint>
<web-resource-collection>
<web-resource-name>All</web-resource-name>
<url-pattern>/*</url-pattern>
</web-resource-collection>
<user-data-constraint>
<description>Ensure to allow only confidential communication</description>
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
</user-data-constraint>
</security-constraint>
<!-- For FORM authentication -->
<login-config>
<auth-method>FORM</auth-method>
<form-login-config>
<form-login-page>/login.jsp</form-login-page>
<form-error-page>/login.jsp?error=true</form-error-page>
</form-login-config>
</login-config>
Next in one of the servlet filters I am calling:
if (CommonUtils.isNullOrEmpty(user)) {
response.setHeader( "auth-msg", "auth-required");
request.authenticate(response);
return;
}
In the browser, upon hitting the /home url, I am always getting a 200 OK response with the above "auth-msg" header set in the response and a blank page. The expected behavior is to take the user to the login page but that doesn't happen. The "Enable application security" is also checked in the WAS console. What else could be missing here? The only workaround here is to explicitly hit the login.jsp page. The login page shows up and I can login from there and things work. But the automatic redirection to login page isn't happing. The same setup works fine in WAS liberty.