0

I want to secure my admin pages in tomcat with web.xml and tomcat-users.xml.It doesn't works.

Here is my contents of my tomcat-users.xml

 <?xml version='1.0' encoding='utf-8'?>
 <tomcat-users>
 <role rolename="webadmin"/>
 <user username="kumar" password="kumar" roles="manager"/>
 </tomcat-users> 

and contents of WEB-INF/web.xml

    <resource-env-ref>
    <description>abc.com/</description>
    <resource-env-ref-name>player</resource-env-ref-name>
    <resource-env-ref-type>org.apache.catalina.UserDatabase</resource-env-ref-type>
     </resource-env-ref>


     <security-constraint>
     <display-name>player</display-name>
     <web-resource-collection>
     <web-resource-name>personal</web-resource-name>

     <!-- Define the context-relative URL(s) to be protected -->


     <url-pattern>abc.com</url-pattern>
     <!-- If you list http methods, only those methods are protected -->

     <http-method>DELETE</http-method>

     <http-method>GET</http-method>

     <http-method>POST</http-method>

     <http-method>PUT</http-method>

  </web-resource-collection>
  <auth-constraint>
     <!-- Anyone with one of the listed roles may access this area -->
     <role-name>webadmin</role-name>
  </auth-constraint>
</security-constraint>

<!-- Default login configuration uses form-based authentication -->
<login-config>
     </form-login-config>-->
  <auth-method>BASIC</auth-method>
  <realm-name>player</realm-name>
</login-config>

<!-- Security roles referenced by this web application -->
 <security-role>
<role-name>webadmin</role-name>
 </security-role>

please let me know what needs to be added in these xmls.

4

1 回答 1

1

就访问 tomcat manager GUI 而言,在 tomcat-users.xml 中没有设置“管理员”角色。

您必须指定这些角色之一。

您可以在 Manager Web 应用程序的 web.xml 文件中找到角色名称。可用的角色有: •<strong>ma​​nager-gui — 访问 HTML 界面。•<strong>ma​​nager-status — 只能访问“服务器状态”页面。•<strong>ma​​nager-script — 访问本文档中描述的工具友好的纯文本界面,以及“服务器状态”页面。•<strong>ma​​nager-jmx — 访问 JMX 代理接口和“服务器状态”页面。

查看此链接以获取更多信息, http: //tomcat.apache.org/tomcat-7.0-doc/manager-howto.html

我希望它有帮助,谢谢。

于 2013-09-19T22:04:08.417 回答