Skip to content

天楚锐齿

人工智能 云计算 大数据 物联网 IT 通信 嵌入式

天楚锐齿

  • 下载
  • 物联网
  • 云计算
  • 大数据
  • 人工智能
  • Linux&Android
  • 网络
  • 通信
  • 嵌入式
  • 杂七杂八

Wildfly把部分url强制为只能https访问方式,其他url可以http访问

2018-07-10
    一个网站,把登录、注册部分的代码强制为https访问,其他内容类的使用http或https访问皆可,我们可以这样配置,使用WEB-INF/web.xml文件的security-constraint条目来实现。
原理,wildfly的security-constraint条目:
    这个security-constraint包含一个或多个web-resource-collection条目,web-resource-collection条目包含一系列可选的url-pattern(比如<url-pattern>/car_public/register</url-pattern>,又比如<url-pattern>/car_public/*</url-pattern>),后面再加一系列可选的http-method(比如<http-method>POST</http-method>)。
    auth-constraint这里不多讲,就是使用鉴权角色来控制对这些url的访问。
    user-data-constraint条目指定客户端到服务端的传输层安全需求,transport-guarantee包含三种类型的值:NONE、INTEGRAL、CONFIDENTIAL,其中NONE表示不需要传输层安全保护,INTEGRAL表示需要保证客户端和服务器端的传输数据完整性,CONFIDENTIAL表示需要保证客户端和服务器端的数据不被其他人窥探读写,一般来讲INTEGRAL和CONFIDENTIAL就是使用SSL(就是HTTPS)来传输,和WILDFLY_HOME/standalone/configuration/standalone.xml相对应:
<https-listener name=”https” socket-binding=”https” max-post-size=”974247881″ max-header-size=”974247881″ security-realm=”ApplicationRealm” enable-http2=”true”/>
…
<socket-binding name=”https” port=”${jboss.https.port:8443}”/>
…
<security-realm name=”ApplicationRealm”>
                <server-identities>
                    <ssl>
                        <keystore path=”cloud.car-ocean.com.keystore” relative-to=”jboss.server.config.dir” keystore-password=”car-ocean” alias=”server” key-password=”car-ocean” generate-self-signed-certificate-host=”cloud.car-ocean.com”/>
                    </ssl>
                </server-identities>
                <authentication>
                    <local default-user=”$local” allowed-users=”*” skip-group-loading=”true”/>
                    <properties path=”application-users.properties” relative-to=”jboss.server.config.dir”/>
                </authentication>
                <authorization>
                    <properties path=”application-roles.properties” relative-to=”jboss.server.config.dir”/>
                </authorization>
</security-realm>
举例(web.xml例子,这样/car_public/register必须使用https方式来访问,使用http来访问则会返回404):
…
    <security-constraint>
        <web-resource-collection>
            <web-resource-name>WEB_APPLICATION_NAME</web-resource-name>
            <url-pattern>/car_public/register</url-pattern>
            <url-pattern>/car_public/sms_verify</url-pattern>
        </web-resource-collection>
        <user-data-constraint>
            <transport-guarantee>CONFIDENTIAL</transport-guarantee>
        </user-data-constraint>
    </security-constraint>
</web-app>
当然,如果所有http都要重定向到https,则更简单:
<socket-binding name=”http” port=”${jboss.https.port:80}”/>
<socket-binding name=”https” port=”${jboss.https.port:8443}”/>
<socket-binding name=”https-ext” port=”${jboss.https.port:443}”/>
把 http://xxx/ 重定向到 https://xxx/ :
<http-listener name=”default” socket-binding=”http” redirect-socket=”https-ext” />
把 http://xxx/ 重定向到 https://xxx:8443/ :
<http-listener name=”default” socket-binding=”http” redirect-socket=”https” />
1,954次阅读

Post navigation

前一篇:

天楚闹钟app,响铃时实现拉起第三方音乐、听书、英语app进行播放

后一篇:

4G/5G时代汽车车机新玩法

发表评论 取消回复

邮箱地址不会被公开。 必填项已用*标注

个人介绍

需要么,有事情这里找联系方式:关于天楚锐齿

=== 美女同欣赏,好酒共品尝 ===

微信扫描二维码赞赏该文章:

扫描二维码分享该文章:

分类目录

  • Linux&Android (79)
  • Uncategorized (1)
  • 下载 (28)
  • 云计算 (37)
  • 人工智能 (8)
  • 大数据 (24)
  • 嵌入式 (34)
  • 杂七杂八 (34)
  • 物联网 (59)
  • 网络 (23)
  • 通信 (21)

文章归档

近期文章

  • 使用Python渲染OpenGL的.obj和.mtl文件
  • 用LVGL图形库绘制二维码
  • Android使用Messenger和SharedMemory实现跨app的海量数据传输
  • CAN信号的c语言解析代码
  • QT qml下DBus的使用例子

近期评论

  • 硕发表在《使用Android的HIDL+AIDL方式编写从HAL层到APP层的程序》
  • maxshu发表在《使用Android的HIDL+AIDL方式编写从HAL层到APP层的程序》
  • Ambition发表在《使用Android的HIDL+AIDL方式编写从HAL层到APP层的程序》
  • Ambition发表在《使用Android的HIDL+AIDL方式编写从HAL层到APP层的程序》
  • maxshu发表在《Android9下用ethernet 的Tether模式来做路由器功能》

阅读量

  • 使用Android的HIDL+AIDL方式编写从HAL层到APP层的程序 - 16,806次阅读
  • 卸载深信服Ingress、SecurityDesktop客户端 - 12,078次阅读
  • 车机技术之Android Automotive - 6,661次阅读
  • 车机技术之车规级Linux-Automotive Grade Linux(AGL) - 5,862次阅读
  • Linux策略路由及iptables mangle、ip rule、ip route关系及一种Network is unreachable错误 - 5,711次阅读
  • 在Android9下用ndk编译vSomeIP和CommonAPI以及使用例子 - 5,658次阅读
  • linux下的unbound DNS服务器设置详解 - 5,601次阅读
  • linux的tee命令导致ssh客户端下的shell卡住不动 - 4,998次阅读
  • 车机技术之360°全景影像(环视)系统 - 4,897次阅读
  • libwebp(处理webp图像)的安装和使用 - 4,749次阅读

功能

  • 文章RSS
  • 评论RSS

联系方式

地址
深圳市科技园

时间
周一至周五:  9:00~12:00,14:00~18:00
周六和周日:10:00~12:00

标签

android AT命令 centos Hadoop hdfs ip ipv6 kickstart linux mapreduce mini6410 modem OAuth openstack os python socket ssh uboot 内核 协议 安装 嵌入式 性能 报表 授权 操作系统 数据 数据库 月报 模型 汽车 测试 深信服 深度学习 源代码 神经网络 统计 编译 网络 脚本 虚拟机 调制解调器 车机 金融
© 2023 天楚锐齿