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” />
838次阅读

Post navigation

前一篇:

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

后一篇:

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

发表评论 取消回复

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

个人介绍

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

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

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

扫描二维码分享该文章:

分类目录

  • Linux&Android (71)
  • 下载 (28)
  • 云计算 (36)
  • 人工智能 (8)
  • 大数据 (23)
  • 嵌入式 (24)
  • 杂七杂八 (34)
  • 物联网 (48)
  • 网络 (22)
  • 通信 (20)

文章归档

近期文章

  • Android下使用pm disable命令或package-restrictions.xml配置文件来禁止某个app的使用或自启动
  • 使用gperftools和btrace来分析java的堆外内存泄露
  • Android下的socket怎么区分不同Network的
  • 使用GitBash同步android AOSP源码以及使用国内镜像来做本地AOSP镜像
  • Android9下用ethernet 的Tether模式来做路由器功能

近期评论

  • maxshu发表在《腾讯云主机默认配置下/run分区空间占满的问题》
  • llipengbo发表在《腾讯云主机默认配置下/run分区空间占满的问题》
  • maxshu发表在《使用GitBash同步android AOSP源码以及使用国内镜像来做本地AOSP镜像》
  • 林先生发表在《支持农历提醒的生日提醒、节假日提醒app》
  • max发表在《ARM交叉编译环境》

阅读量

  • 使用Android的HIDL+AIDL方式编写从HAL层到APP层的程序 - 3,252次阅读
  • 车机技术之Android Automotive - 2,809次阅读
  • 车机技术之车规级Linux-Automotive Grade Linux(AGL) - 2,587次阅读
  • 卸载深信服Ingress、SecurityDesktop客户端 - 2,043次阅读
  • 某云计算中心网络架构图 - 1,844次阅读
  • ISO27000 信息技术安全系列标准 - 1,796次阅读
  • linux的tee命令导致ssh客户端下的shell卡住不动 - 1,750次阅读
  • 车机技术之360°全景影像(环视)系统 - 1,696次阅读
  • 关于天楚锐齿 - 1,654次阅读
  • Linux策略路由及iptables mangle、ip rule、ip route关系及一种Network is unreachable错误 - 1,567次阅读

功能

  • 文章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 内核 协议 安装 嵌入式 性能 报表 授权 操作系统 数据 数据库 月报 模型 汽车 测试 深信服 深度学习 源代码 神经网络 统计 编译 网络 脚本 虚拟机 调制解调器 车机 金融
© 2021 天楚锐齿