java - websphere liberty - 在没有用户身份验证的情况下为站点强制使用 https

标签 java ssl websphere-liberty

我想将 websphere liberty 配置文件配置为仅通过 https 提供页面。特别是,应该阻止对 http 的请求,或者将其重定向到 https。

我已经设置了<security-constraint>在 web.xml 中如下:

<security-constraint>
    <display-name>UserConstraint</display-name>

    <web-resource-collection>
        <web-resource-name>UserCollection</web-resource-name>
        <url-pattern>/*</url-pattern>
        <http-method>GET</http-method>
        <http-method>PUT</http-method>
        <http-method>HEAD</http-method>
        <http-method>TRACE</http-method>
        <http-method>POST</http-method>
        <http-method>DELETE</http-method>
        <http-method>OPTIONS</http-method>
    </web-resource-collection>
    <user-data-constraint>
        <transport-guarantee>CONFIDENTIAL</transport-guarantee>
    </user-data-constraint>
</security-constraint>

我还添加了 [ssl-1.0]功能和默认 keystore 。这会导致 HTTPS 正常工作,但是仍然可以通过 HTTP 访问所有页面(它不会重定向或阻止)。

接下来我添加了特征 [appSecurity-2.0] ,这会导致 HTTP 正确重定向到 HTTPS。但是,我在控制台中看到以下错误:

[ERROR   ] CWWKS3005E: A configuration exception has occurred. No UserRegistry implementation service is available.  Ensure that you have a user registry configured.

如前所述,我没有在 server.xml 中设置用户注册表,因为身份验证是在应用程序本身中完成的。在不更改应用程序以使用用户注册表的情况下,应该如何解决此错误?

此外,web.xml 中是否需要任何其他配置来防止通过 HTTP 进行访问?我本以为 <security-constraint>够了吗?

编辑:我正在发送一个 Basic Auth header 来进行身份验证,以防不清楚。

最佳答案

最简单的做法是在 server.xml 中禁用 http 端口:

<httpEndpoint id="defaultHttpEndpoint" httpPort="-1"/>

关于java - websphere liberty - 在没有用户身份验证的情况下为站点强制使用 https,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31112191/

相关文章:

hibernate - JPA 2.1 与 Liberty Profile 16.0.0.4 的集成问题

java - Bluemix 和 Java Server Faces

java - jTable swing获取输入问题

java - getRequestDispatcher 如何在同一服务器的不同项目中为 servlet 工作?

ssl - nginx v1.10.2 Passenger 403 Homebrew 升级

linux - 使用 ECDSA 证书问题 boost asio

java - 如何在 Jboss 5.1.0 中启用 SSL

MicroProfile 的 WebSphere Application Server 支持

java - 在 MotionEvent.ACTION_MOVE 上重绘 View

java - 无法在Cloudera VM中使用java(在Eclipse中)连接到hbase