【发布时间】:2021-05-28 16:35:27
【问题描述】:
我正在为现有的 Spring 项目实施 ADFS 支持。 由于我们已经有了自己的 JWT 身份验证,我们希望与 ADFS 身份验证并行工作,因此我想实现一个新的过滤器链,它只处理某些 API 请求路径。 我的意思是我想创建:
- 将处理所有 /adfs/saml/** API 调用的 ADFS 过滤器链
- 保留将处理所有其余 API 调用的默认过滤器链
我正在使用ADFS spring security lib 来定义过滤器链,如下所示:
public abstract class SAMLWebSecurityConfigurerAdapter extends WebSecurityConfigurerAdapter {
//some code
protected final HttpSecurity samlizedConfig(final HttpSecurity http) throws Exception {
http.httpBasic().authenticationEntryPoint(samlEntryPoint())
.and()
.csrf().ignoringAntMatchers("/saml/**")
.and()
.authorizeRequests().antMatchers("/saml/**").permitAll()
.and()
.addFilterBefore(metadataGeneratorFilter(), ChannelProcessingFilter.class)
.addFilterAfter(filterChainProxy(), BasicAuthenticationFilter.class);
// store CSRF token in cookie
if (samlConfigBean().getStoreCsrfTokenInCookie()) {
http.csrf()
.csrfTokenRepository(csrfTokenRepository())
.and()
.addFilterAfter(new CsrfHeaderFilter(), CsrfFilter.class);
}
return http;
}
}
我扩展了这个类:
@EnableWebSecurity
@Configuration
@Order(15)
@RequiredArgsConstructor
public class ADFSSecurityConfiguration extends SAMLWebSecurityConfigurerAdapter {
@Override
protected void configure(final HttpSecurity http) throws Exception {
samlizedConfig(http)
.authorizeRequests()
.antMatchers("/adfs")
.authenticated();
}
}
但是在调试时我看到这个新的过滤器链被设置为匹配“任何”请求。 所以我可能把匹配器设置错了。
【问题讨论】:
标签: spring spring-security adfs matcher spring-security-rest