私は、トンネルのガイドを通して作成したSpring Security用のXML設定を持っています。 URLを傍受し、カスタムフィルタを使用してLDAP認証マネージャで認証を提供することになっています。Spring Security XML Config対Java Config
だからここにある:
<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>
今私は、Javaコンフィグでそれを書き換えしようとしています。しかし、そこにカスタムフィルターを使用する方法はありません。 .addFilterBeforeがありますが、前に= "LAST"または前に= PRE_AUTH_FILTERを置くことはできません。そんなことはないから。これをどのように書き換えることができますか?
@Configuration
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Autowired
GenericFilterBean statelessAuthFilter;
@Autowired
AbstractAuthenticationProcessingFilter statelessLoginFilter;
public SecurityConfig(){
}
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.antMatchers("/one**", "/two**").access("hasRole('ONE')")
.antMatchers("/login").permitAll()
.anyRequest().authenticated()
.and()
.addFilterBefore(statelessAuthFilter, GenericFilterBean.class)
.addFilterBefore(statelessLoginFilter, BasicAuthenticationFilter.class)
.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS)
.and().anonymous()
.and().csrf().disable();
}}
大きな説明。そしてそれは動作します)ありがとう! – ottercoder