【问题标题】:How do you add basic authentication to tomcat when using Eclipse?使用 Eclipse 时如何向 tomcat 添加基本身份验证?
【发布时间】:2011-11-29 21:03:46
【问题描述】:

问题定义:

我们有一个面向公众的 tomcat,我们希望仅在面向 tomcat 的产品上使用单一密码保护 web 应用程序。这可以通过向生产 tomcat-users.xml 添加一个新的用户和角色并将相应的和部分添加到 webapps WEB-INF/web.xml 来完成

问题是,因为您必须更改实际的 webapp,这意味着使用 eclipse 的开发人员无法访问该站点,除非他们删除这些行并记住在发布之前重新应用它们。无法编辑 eclipse tomcats tomcat-users.xml(在 workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/conf 中找到,因为它会在您停止/启动 tomcat 时被覆盖。

问题:

有没有其他方法只在服务器上进行身份验证,或者让用户进入 eclipses tomcat?

以下是进入 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>gamer</role-name>
  </auth-constraint>
</security-constraint>
<!-- Define the Login Configuration for this Application -->
<login-config>
  <auth-method>BASIC</auth-method>
  <realm-name>Invigation only</realm-name>
</login-config>

【问题讨论】:

    标签: eclipse tomcat basic-authentication


    【解决方案1】:

    一个蛮力解决方案是在最终构建过程中使用脚本将所需的内容添加到 web.xml 中。它不干净,我相信有更好的方法,但它消除了开发人员的痛点。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-09-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-03-22
      • 2022-06-10
      相关资源
      最近更新 更多