gpt4 book ai didi

ssl - 如何为所有子位置强制执行 https 连接? JAX-RS JBoss

转载 作者:太空宇宙 更新时间:2023-11-03 15:03:38 25 4
gpt4 key购买 nike

以下部分应强制所有客户端使用 https 连接。

<security-constraint>
<web-resource-collection>
<web-resource-name>securedapp</web-resource-name>
<url-pattern>/*</url-pattern>
</web-resource-collection>
<user-data-constraint>
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
</user-data-constraint>
</security-constraint>

实际情况是只有 index.html 页面受 ssl 保护。所以像这样的请求:http://localhost/JAX-RS_Service/被重定向到 https://localhost/JAX-RS_Service/并显示 index.html 页面。 http://localhost/JAX-RS_Service/index.html也是如此但是如果我尝试请求 http://localhost/JAX-RS_Service/services/customers/1 ,没有重定向到 https,因此所有内容都通过网络以明文形式发送。

同样是强制认证

<security-constraint>
<web-resource-collection>
<web-resource-name>Authenticated customers only</web-resource-name>
<url-pattern>/services/customers/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>CUST</role-name>
</auth-constraint>
</security-constraint>

类似 <url-pattern>/services/*</url-pattern> 的 url 模式不会完成这项工作。

为什么不是 <url-pattern>/*</url-pattern>为 subloacations 工作。有办法解决这个问题吗?

最佳答案

其实我也不知道为什么,但是下面的配置解决了我的问题。

    <security-constraint>
<web-resource-collection>
<web-resource-name>SSL Secured WebService</web-resource-name>
<url-pattern>/*</url-pattern>
</web-resource-collection>
<user-data-constraint>
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
</user-data-constraint>
</security-constraint>

<security-constraint>
<web-resource-collection>
<web-resource-name>Authenticated customers only</web-resource-name>
<url-pattern>/services/customers/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>CUST</role-name>
</auth-constraint>
<user-data-constraint>
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
</user-data-constraint>
</security-constraint>

<user-data-constraint>
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
</user-data-constraint>
需要在每个 <security-constraint> 中添加否则它不适用于 JBoss。有趣的是,对于 Tomcat,您必须定义 <transport-guarantee>CONFIDENTIAL</transport-guarantee> <url-pattern>/*</url-pattern> 一次一次一切都得到妥善保护。在我看来,这更合理!

关于ssl - 如何为所有子位置强制执行 https 连接? JAX-RS JBoss,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16385595/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com