首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >禁用特定URL上的标头

禁用特定URL上的标头
EN

Stack Overflow用户
提问于 2017-09-06 19:41:28
回答 2查看 292关注 0票数 1

Spring非常新,所以这可能是基本的。最近,我们已经从Spring 3转换到了4,并且遇到了一些与我们的合作伙伴业务逻辑相关联的新默认值的头问题。

除了一个特定的URL“/stg/战略板/strg/drammin.syg”之外,我们想在任何地方保留默认值。

目前,我们有:

代码语言:javascript
复制
<http use-expressions="true" entry-point-ref="web.AuthenticaionEntryPoint">
   <intercept-url pattern="/admin/**" access = "hasAnyRole('GKR_ADMIN', 'GKR_ADMIN_ADV')"/>
   <intercept-url pattern="/**" access = "hasAnyRole('GKR_USER')"/>
</http>

我如何配置它,以便“/stg/战略板/strg/drammin.syg”仍然是安全的,但它是应用以下头配置的唯一位置?

代码语言:javascript
复制
<headers defaults-disabled="true">
    <content-type-options />
    <hsts include-subdomains="true" max-age-seconds="31536000"/>
    <frame-options policy="SAMEORIGIN"/>
    <xss-protection block="false"/>
</headers>

更新1:能够使我需要的URL更具体

更新2:我刚刚尝试添加另一个http块,但是我一直得到Spring错误

在筛选链中的其他模式之前定义了一个通用匹配模式('/**'),导致忽略它们。

不管我把这些块按了什么顺序,我甚至试着删除"/**“模式,这个错误仍然出现。

我的尝试:

代码语言:javascript
复制
<http use-expressions="true" entry-point-ref="web.AuthenticaionEntryPoint">
   <intercept-url pattern="/admin/**" access = "hasAnyRole('GKR_ADMIN', 'GKR_ADMIN_ADV')"/>
   <intercept-url pattern="/**" access = "hasAnyRole('GKR_USER')"/>
</http>

<http use-expressions="true" entry-point-ref="web.AuthenticaionEntryPoint">       
    <headers defaults-disabled="true">
        <content-type-options />
        <hsts include-subdomains="true" max-age-seconds="31536000"/>
        <frame-options policy="SAMEORIGIN"/>
        <xss-protection block="false"/>
    </headers>

    <intercept-url pattern="/stg/strategem/strg/drammin.syg" access = "hasAnyRole('GKR_ADMIN', 'GKR_ADMIN_ADV', 'GKR_USER')"/>
</http>

更新3:能够找到解决方案,在答案中查看

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2017-09-07 14:02:12

好吧,伙计们,我可以通过使用一个单独的HTTP块来工作,它有一个模式,但没有拦截URL。试图使这两种配置都具有安全配置是造成问题的原因。

谢谢齐尔维纳斯为我指明了正确的道路。

第一个块只对特定的url应用报头信任。其他一切都会得到Spring的默认值。第二个区块适用安全措施。(包括特定的url,因为我有一个/**通配符)

代码语言:javascript
复制
<http pattern="/stg/strategem/strg/drammin.syg">       
    <headers defaults-disabled="true">
        <content-type-options />
        <hsts include-subdomains="true" max-age-seconds="31536000"/>
        <frame-options policy="SAMEORIGIN"/>
        <xss-protection block="false"/>
    </headers>
</http>

<http use-expressions="true" entry-point-ref="web.AuthenticaionEntryPoint">
   <intercept-url pattern="/admin/**" access = "hasAnyRole('GKR_ADMIN', 'GKR_ADMIN_ADV')"/>
   <intercept-url pattern="/**" access = "hasAnyRole('GKR_USER')"/>
</http>
票数 0
EN

Stack Overflow用户

发布于 2017-09-06 20:04:23

您应该能够为每个块配置不同的多个<http>块。请参阅Spring安全参考-多重安全性

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/46083155

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档