I have following structure in my tomcat web directory
/webapps/ROOT.war
/webapps/ROOT/
/webapps/protect/
In the web.xml inside my ROOT.war java application I have configured basic authentication for some of the pages of the ROOT application which are working perfectly as expected.
But I need the same rules to be applied to the directory "protect" which is not part of that ROOT application. I added these rules to both web.xml inside of the ROOT application and to the web.xml file in /opt/tomcat/conf/ but the directory "protect" is still accessible without authentication. Any ideas?
This is the security configuration which is working for the ROOT paths, but not for the protect path:
<security-constraint>
<web-resource-collection>
<web-resource-name>Some paths need authentication</web-resource-name>
<url-pattern>/rest/*</url-pattern>
<url-pattern>/protect/*</url-pattern>
<http-method>GET</http-method>
<http-method>POST</http-method>
</web-resource-collection>
<auth-constraint>
<role-name>authenticatedUser</role-name>
</auth-constraint>
<user-data-constraint>
<transport-guarantee>NONE</transport-guarantee>
</user-data-constraint>
</security-constraint>
<login-config>
<auth-method>BASIC</auth-method>
</login-config>