Java 在Spring Security 5中,只允许对某些特定url使用分号,例如StrictHttpFirewall?

Java 在Spring Security 5中,只允许对某些特定url使用分号,例如StrictHttpFirewall?,java,spring,spring-security,Java,Spring,Spring Security,我们使用的是primefaces媒体组件,它生成的url为/javax.faces.resource/dynamiccontent.properties;/。包含分号(;)的pdf 因此,我们遇到异常,即请求被拒绝,因为URL包含潜在的恶意字符串。 在Spring Security 5中,默认情况下启用了StrictHttpFirewall更新。 我们可以在StrictHttpFirewall中使用setAllowSemicolon(true)指定允许分号 但这将适用于所有URL 是否有任何方法

我们使用的是primefaces媒体组件,它生成的url为/javax.faces.resource/dynamiccontent.properties;/。包含分号()的pdf

因此,我们遇到异常,即请求被拒绝,因为URL包含潜在的恶意字符串。

在Spring Security 5中,默认情况下启用了StrictHttpFirewall更新。 我们可以在StrictHttpFirewall中使用setAllowSemicolon(true)指定允许分号

但这将适用于所有URL


是否有任何方法可以配置为只允许特定URL使用分号?

如果使用xml配置,请声明bean:

<bean id="customStrictHttpFirewall"
    class="org.springframework.security.web.firewall.StrictHttpFirewall">
    <property name="allowSemicolon" value="true"/>
</bean>

然后在security.xml ref中:

<http-firewall ref="customStrictHttpFirewall"/>


如果您使用注释,您可以搜索答案,

如上所述,我还为允许分号的自定义防火墙添加了以下XML定义

<bean id="myHttpFirewall" class="org.springframework.security.web.firewall.StrictHttpFirewall">
    <property name="allowSemicolon" value="true"/>
</bean>

<security:http-firewall ref="myHttpFirewall"/>

然而,比亚迪本身对此没有影响。要在我的应用程序中使用该防火墙,我必须将其添加到我的FilterChainProxy中,如下所示:

<bean id="filterChainProxy" class="org.springframework.security.web.FilterChainProxy">
    <constructor-arg>
        <list>
            <security:filter-chain pattern="/**" filters="...."/>
        </list>
    </constructor-arg>
    <property name="firewall" ref="myHttpFirewall"/>
</bean>