tomcat中受密码保护的应用程序

编程入门 行业动态 更新时间:2024-10-18 01:41:29
本文介绍了tomcat中受密码保护的应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在使用(JSP + Servlet)开发一个Web应用程序,我使用 Tomcat 7.0.33 作为 web容器。

I am developing a web application using(JSP + Servlet), and I have used Tomcat 7.0.33 as a web container.

所以我的要求是tomcat中的每个应用程序都将密码受保护,就像 manager应用程序受到保护。

So my requirement is that each application in tomcat will be password protected like the manager application in tomcat is protected.

到目前为止,我已完成以下操作:

So far I have done following:

server.xml

<Realm className="org.apache.catalina.realm.MemoryRealm" />

tomcat-users.xml

<tomcat-users> <role rolename="tomcat"/> <role rolename="manager-gui"/> <role rolename="role1" /> <user username="tomcat" password="tomcat" roles="role1,tomcat,manager-gui"/> <user username="role1" password="tomcat" roles="role1"/> </tomcat-users>

web.xml

<security-role> <role-name>role1</role-name> </security-role> <security-role> <role-name>tomcat</role-name> </security-role> <security-constraint> <web-resource-collection> <web-resource-name>webappname</web-resource-name> <url-pattern>/*</url-pattern> </web-resource-collection> <auth-constraint> <role-name>role1</role-name> <role-name>tomcat</role-name> </auth-constraint> </security-constraint> <login-config> <auth-method>BASIC</auth-method> <realm-name>webappname</realm-name> </login-config>

任何人按应用程序路径打开应用程序时都会正常工作(它要求输入用户名和密码,以及应用程序接受 role1 或 tomcat 进行身份验证。

It works fine when anyone opens the application by application path(it asks for username & password, and application accepts either of the role1 or tomcat for authentication).

但问题是假设我以具有所有角色的用户 tomcat 登录,并且当显示管理器屏幕时列出了部署在其上的所有应用程序服务器,然后如果我尝试打开 mywebapplication ,那么它再次要求输入用户名和密码。

But the Issue is that suppose if I login as a user tomcat who has got all roles, and when the manager screen is shown which lists all the application deployed on the server, then if I try to open mywebapplication then it again asks for username and password.

我的问题是如果我已将所有角色分配给用户 tomcat ,那么为什么如果我以 Tomcat的?有没有办法避免这种情况?

My question is that if I have assigned all the roles to the user tomcat then why it asks for password if I have login as tomcat? is there any way to avoid this?

提前致谢。

推荐答案

<login-config> <auth-method>BASIC</auth-method> <realm-name>webappname</realm-name> </login-config>

基本身份验证凭据在安全领域中进行组织。如果您为所有应用程序提供不同的Realm-Names,浏览器将提示每个应用程序。尝试为所有这些使用相同的名称(如果这是你想要的)。

Basic Auth credentials are organized in "Security Realms". If you give all your apps different Realm-Names, the browser will prompt for each. Try using the same name for all of them (if that is what you want).

更多推荐

tomcat中受密码保护的应用程序

本文发布于:2023-11-27 07:57:11,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1637182.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:密码保护   应用程序   tomcat

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!