【问题标题】:Security Issue on many user accounts (Java, Tomcat, Web)许多用户帐户(Java、Tomcat、Web)的安全问题
【发布时间】:2013-01-29 11:37:23
【问题描述】:

我的服务器上有几个页面具有不同的角色和用户,并配置了基本身份验证。

当我成功登录第一页然后尝试打开另一个我的页面(在另一个选项卡中)时,我只看到错误:HTTP 状态 403 - 对请求的资源的访问被拒绝。 要成功打开另一个页面,我需要关闭并重新打开浏览器。

预期行为:我在新选项卡中打开另一个页面,我看到新的登录对话框,用于输入新页面的登录名和密码。

这是我的配置:

tomcat-users.xml:

  <role rolename="Role1"/>
  <role rolename="Role2"/>

  <user username="user1" password="pass1" roles="Role1"/>
  <user username="user2" password="pass2" roles="Role2"/>

web.xml 的一部分:

 <security-constraint>
      <web-resource-collection>
       <web-resource-name>Info Page</web-resource-name>
       <url-pattern>/DeploymentInfoService</url-pattern>
      </web-resource-collection>
      <auth-constraint>
       <role-name>Role1</role-name>
      </auth-constraint>
     </security-constraint>

     <security-constraint>
      <web-resource-collection>
       <web-resource-name>RSS Feeds</web-resource-name>
       <url-pattern>/RssFeedService</url-pattern>
      </web-resource-collection>
      <auth-constraint>
       <role-name>Role2</role-name>
      </auth-constraint>
     </security-constraint>

     <security-role>
      <role-name>Role1</role-name>
     </security-role>

     <security-role>
      <role-name>Role2</role-name>
     </security-role>

     <login-config>
      <auth-method>BASIC</auth-method>
      <realm-name>OnJava Application</realm-name>
     </login-config>

【问题讨论】:

    标签: java tomcat


    【解决方案1】:

    您将每个页面限制为一个角色,并且您有 2 个用户,每个用户具有不同的角色。
    所以user1只能访问DeploymentInfoService页面,user2只能访问RssFeedService页面。如果您希望他们中的任何一个访问另一个页面,您必须授予他们另一个角色,或者在该页面上允许更多角色。

    【讨论】:

    • 不,你对我的问题的理解不正确。我正在尝试使用不同的用户名访问另一个页面(只是忘记了上一页),但我做不到。浏览器没有弹出我的登录/密码表单,我只是收到上述错误
    猜你喜欢
    • 1970-01-01
    • 2011-02-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-11-07
    • 1970-01-01
    • 2013-01-05
    • 1970-01-01
    相关资源
    最近更新 更多