How to configure tomcat-users.xml to secure a page in tomcat?

前端 未结 1 1478
借酒劲吻你
借酒劲吻你 2020-12-11 09:13

I\'m trying to secure my admin pages in tomcat with web.xml and tomcat-users.xml but it\'s not working. The login form appears but connection is im

相关标签:
1条回答
  • 2020-12-11 09:46

    Probably late to answer but anyways You are missing role in in you web.xml and also dont have to mention realm hence you web.xml should look like as follows

    <security-constraint>
       <web-resource-collection>
          <web-resource-name>Admin</web-resource-name>
          <url-pattern>/admin/*</url-pattern>
        </web-resource-collection>
        <auth-constraint>
          <role-name>admin</role-name>
        </auth-constraint>
     </security-constraint>
     <login-config>
           <auth-method>BASIC</auth-method>
          <!-- Please note following line .. its commented -->
          <!-- <realm-name>Admin</realm-name> -->
     </login-config>
     <!-- Following section was missing -->
     <security-role>
         <role-name>admin</role-name>
    </security-role>
    
    0 讨论(0)
提交回复
热议问题