如何解决Spring Saml 身份验证失败重定向到角度路由不起作用
我有角度错误路由(/#/error)需要在服务提供商的 saml 身份验证失败后重定向。但是在重定向到错误路由后,它立即再次重定向到 IDP 进行身份验证。
下面是配置
@Override
public void configure(WebSecurity web) throws Exception {
web.ignoring().antMatchers("/#/error");
}
@Override
protected void configure(HttpSecurity http) throws Exception {
final CookieCsrftokenRepository cookieCsrftokenRepository = new CookieCsrftokenRepository();
cookieCsrftokenRepository.setCookieHttpOnly(false);
http.authorizeRequests().antMatchers("/saml/**","/error").permitAll().antMatchers("/**").fullyAuthenticated()
.anyRequest().authenticated();
http.exceptionHandling().defaultAuthenticationEntryPointFor(samlEntryPoint,new AntPathRequestMatcher("/"));
http.csrf().disable();
http.addFilterBefore(MetadataGeneratorFilter(),ChannelProcessingFilter.class)
.addFilterBefore(new CustomCsrfFilter(cookieCsrftokenRepository),MetadataGeneratorFilter.class)
.addFilterBefore(new SecurityFilter(),CustomCsrfFilter.class);
http.addFilterafter(samlFilter(samllogoutFilter,samlEntryPoint,samlAuthSuccessHandler,samlAuthFailureHandler,samllogoutProcessingFilter),BasicAuthenticationFilter.class);
}
@Bean
@Qualifier("saml")
public SimpleUrlAuthenticationFailureHandler authenticationFailureHandler() {
SimpleUrlAuthenticationFailureHandler failureHandler = new SimpleUrlAuthenticationFailureHandler();
failureHandler.setUseForward(true);
failureHandler.setDefaultFailureUrl("/authentication-failure");
return failureHandler;
}
A controller class for above authentication failure url.
@PostMapping(value = { "/authentication-failure" })
public String errorHandler(final HttpServletRequest request) {
return "redirect:/#/error";
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。