我想在我的tomcat应用程序上启用基本的HTTPvalidation。 此外,我想保持在应用程序之外。 我向tomcat-users.xml添加了一个新用户,并将其angular色设置为“app-user”。 然后我添加了一个文件$ CATALINA_HOME / conf / Catalina / localhost / myapp.xml以下内容。 但是,tomcat完全无视它。 我究竟做错了什么?
<Context path="/myapp"> <security-constraint> <web-resource-collection> <web-resource-name> Wildcard means whole app requires authentication </web-resource-name> <url-pattern>/*</url-pattern> <http-method>GET</http-method> <http-method>POST</http-method> </web-resource-collection> <auth-constraint> <role-name>app-user</role-name> </auth-constraint> <user-data-constraint> <!-- transport-guarantee can be CONFIDENTIAL, INTEGRAL, or NONE --> <transport-guarantee>NONE</transport-guarantee> </user-data-constraint> </security-constraint> <login-config> <auth-method>BASIC</auth-method> </login-config> </Context>
<security-constraint>标签属于应用程序的web.xml(通常在你的战争的WEB-INF/web.xml中)。
如果你真的想把它保存在你的应用程序之外,那么你可以将它添加到conf/web.xml文件中,但是请记住,它将被应用到你的tomcat中的任何其他webapps。