【发布时间】:2017-04-09 00:22:10
【问题描述】:
我有一个使用 Jersey 作为 JAX-RS 实现的 Spring Boot 应用程序。这是我的安全配置:
@Configuration
@EnableGlobalMethodSecurity(prePostEnabled = true)
@EnableWebSecurity
public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
@Autowired TokenAuthenticationProvider tokenAuthenticationProvider;
@Override
public void configure(AuthenticationManagerBuilder auth) throws Exception {
auth.authenticationProvider(tokenAuthenticationProvider);
}
@Override
protected void configure(HttpSecurity http) throws Exception {
http.addFilterBefore(new AuthenticationTokenFilter(), BasicAuthenticationFilter.class)
.csrf().disable()
.authorizeRequests()
.antMatchers("/dataHub/**")
.authenticated();
}
}
我想要做的是有一种方法来捕获我的 TokenAuthenticationProvider 抛出的异常,并将它们转换为我们同意的标准化 JSON 格式。有没有办法做到这一点?我尝试添加自定义的 AuthenticationFailureHandler,但无法使其正常工作。
【问题讨论】:
标签: spring rest spring-security spring-boot jersey