Spring非常新,所以这可能是基本的。最近,我们已经从Spring 3转换到了4,并且遇到了一些与我们的合作伙伴业务逻辑相关联的新默认值的头问题。
除了一个特定的URL“/stg/战略板/strg/drammin.syg”之外,我们想在任何地方保留默认值。
目前,我们有:
<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”仍然是安全的,但它是应用以下头配置的唯一位置?
<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错误
在筛选链中的其他模式之前定义了一个通用匹配模式('/**'),导致忽略它们。
不管我把这些块按了什么顺序,我甚至试着删除"/**“模式,这个错误仍然出现。
我的尝试:
<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:能够找到解决方案,在答案中查看
发布于 2017-09-07 14:02:12
好吧,伙计们,我可以通过使用一个单独的HTTP块来工作,它有一个模式,但没有拦截URL。试图使这两种配置都具有安全配置是造成问题的原因。
谢谢齐尔维纳斯为我指明了正确的道路。
第一个块只对特定的url应用报头信任。其他一切都会得到Spring的默认值。第二个区块适用安全措施。(包括特定的url,因为我有一个/**通配符)
<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>发布于 2017-09-06 20:04:23
您应该能够为每个块配置不同的多个<http>块。请参阅Spring安全参考-多重安全性
https://stackoverflow.com/questions/46083155
复制相似问题