简体   繁体   English

Tomcat身份验证和特定的Web应用程序身份验证

[英]Tomcat authentication and specific web app authentication

I config my tomcat with the following configuration in the web.xml. 我在web.xml中使用以下配置配置了tomcat。 So now I secure all webapps in the folder webapps. 因此,现在我将所有webapp都保护在文件夹webapps中。 The user has to authenticate himself, before he can visit the web apps. 用户必须先进行身份验证,然后才能访问Web应用程序。

<security-constraint>
  <web-resource-collection>
    <web-resource-name>
      My Application
    </web-resource-name>
    <url-pattern>/*</url-pattern>
    <http-method>GET</http-method>
    <http-method>PUT</http-method>
  </web-resource-collection>
  <auth-constraint>
    <role-name>demo123</role-name>
    <role-name>admin</role-name>
  </auth-constraint>
</security-constraint>
<login-config>
  <auth-method>BASIC</auth-method>
  <realm-name>Secure Apps</realm-name>
</login-config>

After the user logged in, he can visit the requested web app. 用户登录后,他可以访问所请求的Web应用程序。 My problem: In the web apps the user have to logged in (with Basic authentication), because behind there is a specific server with all server logic. 我的问题:在Web应用程序中,用户必须登录(使用基本身份验证),因为在后面是具有所有服务器逻辑的特定服务器。 I use REST Webservices to communicate to that server. 我使用REST Web服务与该服务器进行通信。 But I can't call the webservices because it shows me a 401 Unauthorized. 但是我无法调用Web服务,因为它向我显示了401未经授权。 If I delete the above configuration in the web.xml, I can call these webservices without problems. 如果删除web.xml中的上述配置,则可以毫无问题地调用这些web服务。 Is there a way to secure all webapps in the tomcat another way? 有没有一种方法可以以另一种方式保护Tomcat中的所有Web应用程序? I need it because the webapps needs the basic authentication. 我需要它,因为webapps需要基本身份验证。

For the applications I use spring framework. 对于应用程序,我使用spring框架。

我通过更改url模式解决了它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Tomcat Web应用程序需要使用SSL客户端身份验证吗? - Tomcat web app needs to work with SSL Client authentication? Web应用程序和请求身份验证 - Web app and request authentication Web服务客户端身份验证导致Tomcat中的异常 - Web Service Client authentication leading to exception in Tomcat Tomcat:单个Web应用程序有多种身份验证方案吗? - Tomcat: Multiple authentication schemes for a single web application? 具有Android应用程序的Java / Tomcat服务器中的Windows身份验证 - Windows authentication in a Java/Tomcat server with an Android app 使用WildFly自定义Web应用程序身份验证 - Custom web app authentication with WildFly Web App-如何在Web应用程序中实施身份验证 - Web App - How to implement an authentication in a web app tomcat java web 应用程序的两因素身份验证 - Two-Factor Authentication for a tomcat java web application Tomcat Manager身份验证在运行Java Web项目时重复弹出 - Tomcat Manager Authentication repeated popup while running a Java web project 在Web服务和业务层(Spring,tomcat)之间传递身份验证信息 - Pass authentication info between web service and business layer (Spring, tomcat)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM