0
我試圖保護我的web應用程序在tomcat web.xml
和tomcat-users.xml
但它不工作。正確的登錄名和密碼導致401錯誤。如何在tomcat 8.5中配置基本認證? HTTP錯誤401
我web.xml
安全部分:
<security-constraint>
<web-resource-collection>
<web-resource-name>Web Application</web-resource-name>
<url-pattern>/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>myuser</role-name>
</auth-constraint>
</security-constraint>
<security-role>
<role-name>myuser</role-name>
</security-role>
<login-config>
<auth-method>BASIC</auth-method>
</login-config>
我tomcat-users.xml
:
<?xml version="1.0" encoding="UTF-8"?>
<tomcat-users xmlns="http://tomcat.apache.org/xml"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://tomcat.apache.org/xml tomcat-users.xsd"
version="1.0">
<role rolename="myuser"/>
<role username="myuser" password="myuser" role="myuser"/>
</tomcat-users>
我已經嘗試過這樣做,結果是一樣的。日誌中只有一處更改:'對於帶有URL模式的安全限制[/ *],僅包含HTTP方法[POST GET]。所有其他方法都被發現。' – SemperPeritus
嘗試更新您的'tomcat-users.xml'文件,檢查更新條目 –
謝謝!改變'用戶'上的'角色'作品。我的錯字。 – SemperPeritus