我已经配置tomcat进行基本身份验证.我不希望任何人访问我的Web应用程序,但该应用程序正在提供Web服务.所以我想从基本身份验证中绕过一个特定的IP地址.(该ip不应该要求身份验证.)
tomcat-users.xml:
<tomcat-users>
<user username="user" password="password" roles="user"/>
</tomcat-users>
Run Code Online (Sandbox Code Playgroud)
web.xml:
<security-constraint>
<web-resource-collection>
<web-resource-name>Entire Application</web-resource-name>
<url-pattern>/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>user</role-name>
</auth-constraint>
</security-constraint>
<login-config>
<auth-method>BASIC</auth-method>
<realm-name>You must enter your login credentials to continue</realm-name>
</login-config>
<security-role>
<description>
The role that is required to log in to the Application
</description>
<role-name>user</role-name>
</security-role>
Run Code Online (Sandbox Code Playgroud)
谢谢,Chetan.
tomcat ×1