我有Spring Security的XML配置,我已经通过大量的指南做了。 它应该拦截url,自定义过滤器使用ldap身份验证管理器提供身份验证。
所以这里是:
function debugger(helptext, sensor)
print_message_to_user(
string.format("%s: %d", helptext, sensor_data[sensor](sensor_data))
)
end
debugger("Engine RPM", "getEngineLeftRPM")
现在我正试图用Java Config重写它。但我无法在那里使用自定义过滤器。还有.addFilterBefore但是我不能把它放在=" LAST"之前。或之前=" PRE_AUTH_FILTER"那里。因为没有这样的事情。我怎么能改写这个?
<http create-session="stateless" auto-config='false' use-expressions="true">
<anonymous enabled="true"/>
<intercept-url pattern="/index.html" access="permitAll()" method="GET"/>
<intercept-url pattern="/login" access="permitAll()" method="GET"/>
<custom-filter before="LAST" ref="statelessLoginFilter"/>
<custom-filter before="PRE_AUTH_FILTER" ref="statelessAuthFilter"/>
<intercept-url pattern="/one*" access="hasRole('ROLE_ONE')" method="GET"/>
<intercept-url pattern="/two*" access="hasRole('ROLE_TWO')" method="GET"/>
<!-- another intercept-url stuff -->
<csrf disabled="true"/>
<!-- authentication manager and stuff -->
</http>
答案 0 :(得分:4)
您必须确定特定的过滤器类。
例如,默认的LAST过滤器应为FilterSecurityInterceptor
- Filter Ordering。
PRE_AUTH_FILTER可以是任何扩展AbstractPreAuthenticatedProcessingFilter
的内容,具体取决于您已配置的内容。
基本上,Java Config强迫您明确订购,以避免以后出现令人讨厌的意外。