我想配置websphere serve配置文件,以便仅在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]特性和默认密钥存储。这会导致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>就足够了?
编辑:我正在发送一个基本的Auth头来进行身份验证,以防不清楚。
发布于 2015-07-08 22:58:04
将<basicRegistry></basicRegistry>添加到server.xml中。您的应用程序不会使用它,因为您的security-constraint没有定义任何auth-constraint。
关于你的其他评论:
这可能是服务器试图解释基本的auth头而没有在注册表中找到用户的结果。
但是,如果您无论如何都在使用基本身份验证,则允许服务器通过保护web模块来创建该请求,而不是使用基本注册中心,实现您的自定义注册表作为自由特性(请参阅为自由配置文件开发自定义用户注册表 )会使您受益
发布于 2015-06-29 13:23:40
最简单的方法是禁用server.xml中的http端口:
<httpEndpoint id="defaultHttpEndpoint" httpPort="-1"/>
发布于 2016-04-14 17:21:13
在您的web.xml中添加:
<user-data-constraint>
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
</user-data-constraint>这将重定向到https。
https://stackoverflow.com/questions/31112191
复制相似问题