普元EOS学习笔记-EOS项目HTTP访问安全和权限控制

前言

对于企业应用系统,出于安全和权限控制的目的,需要对http请求做若干控制。

比如文件上传的时候要控制不允许上传的文件后缀。

又比如控制应用程序中的哪些资源不允许被访问。

EOS项目通过 xml配置文件来实现这一需求。

Http访问管理模块

在EOS项目中,Http的请求控制是通过 user-config.xml文件来配置的。

在boot构建包中,可以找到一个 user_config.xml 文件。

编辑 user-config.xml文件,可以找到一个 Access-Http的xml片段。

    <!-- http access configuration-->
    <module name="Access-Http">
        <group name="FileUpload">
            <configValue key="TempDir">upload</configValue>
            <configValue key="MaxSize">104857600</configValue>
            <configValue key="InMemorySize">10240</configValue>
            <!--files with specified ext names are not accespted when uploading  -->
            <configValue key="Exclude">exe,java,jsp,html,htm,class,jar</configValue>
        </group>
        <group name="Encoding">
            <!-- the charset of the incoming HttpServletRequest-->
            <configValue key="Request">UTF-8</configValue>
        </group>
        <group name="Suspend">
            <!-- the time to suspend, waiting for the xsd loading,in seconds.-->
            <configValue key="TimeOut">60</configValue>
        </group>
        <group name="Login-Filter">
            <!-- pages that can be accessed by any one including those not login -->
            <configValue
                    key="Exclude">/api/afc/login/third-party/validate,/api/afc/login/third-party/types,/api/taskcenter/push-task/*,/api/bfp/messagecenter/send-process-message,/api/afc/component-centers,/api/lowcode/resources/*/runtimes,/api/afc/preferences/info/*,/api/lowcode/shares/actions/*,/api/afc/login/clientId,/,*.gif,*.svg,.ttf,*.woff2,*.woff,*.jpg,*.json,*.ico,*.js,*.css,*.png,*.html,/api/afc/oauth2/*,/api/afc/login/third-party/auth,/api/afc/login/third-party/qrConnect,/api/afc/validation-code,/swagger-ui.html,/v2/api-docs,/webjars/*,/swagger-resources/*,/afc,/afc/,/api/afc/login,/api/afc/login/password/key,/actuator/*,/om/*,/common.remote,
                /jmxDefault.jmx,/common.download,/api/afc/materials/font/*,/api/afc/components/*,/api/afc/job/api/*</configValue>
            <!-- <configValue key="Include">*.flow,*.flowx,*.jsp,*.html,*.ajax,*.ext,*.action,*.beanx</configValue> -->
            <configValue key="Include">/*</configValue>
            <!-- the page to display when user not login -->
            <configValue key="LoginPage"></configValue>
        </group>
        <group name="Accessed-Mode">
            <configValue key="Portal">false</configValue>
        </group>
        <group name="Http-Security">
            <configValue key="isOpenSecurity">false</configValue>
            <configValue key="Exclude">**/common.download</configValue>
            <configValue key="regexs">eval\s*?\([^\)]+?\),alert\s*?\([^\)]+?\),new\s+?Function\s*?\([^\)]+?\),window\[[^\]]+?\]\s*?=</configValue>
        </group>
    </module>

这段配置信息的大概意思如下:

  • FileUpload(文件上传):

    • TempDir:指定上传文件的临时目录为 upload
    • MaxSize:设置上传文件的最大大小为 104857600 字节(即 100 MB)。
    • InMemorySize:设置内存中存储的上传文件的最大大小为 10240 字节。
    • Exclude:定义不允许上传的文件扩展名,包括 exe, java, jsp, html, htm, class, jar
  • Encoding(编码):

    • Request:设置接收 HTTP 请求的字符集为 UTF-8
  • Suspend(挂起):

    • TimeOut:设置等待 XSD 加载挂起的超时时间为 60 秒。
  • Login-Filter(登录过滤器):

    • Exclude:列出可以被任何人访问的页面,包括未登录的用户。列出了各种 API 端点和静态资源,如图片、JavaScript、CSS 等等。
    • Include:设置允许所有页面(/*)。
    • LoginPage:定义未登录用户访问时显示的页面。
  • Accessed-Mode(访问模式):

    • Portal:设置为 false,表示未启用门户模式。
  • Http-Security(HTTP 安全):

    • isOpenSecurity:设置为 false,表示未启用 HTTP 安全。
    • Exclude:排除特定的 URL 匹配模式 **/common.download
    • regexs:定义正则表达式模式,用于防止安全漏洞,如 eval, alert, new Function, window[] 的直接赋值。

更细节的解释,就希望各位自己多研究研究了。

什么时候需要维护Access-Http

如果发现EOS项目在浏览器访问的时候,总是提示"登录信息已过期!"

大概率是因为 Login-Filter 这部分的配置出现了问题。

还有,当文件上传出现文件太大,上传失败的问题,也是这个部分的xml需要调整一下。

  • 3
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

小崔爱读书

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值