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