http
// ... your configuration
.exceptionHandling((ex) -> ex
.defaultAuthenticationEntryPointFor(new LoginUrlAuthenticationEntryPoint("/login"), new AntPathRequestMatcher("/ui/**"))
.defaultAuthenticationEntryPointFor(new HttpStatusEntryPoint(HttpStatus.UNAUTHORIZED), new AntPathRequestMatcher("/api/**"))
);
1条答案
按热度按时间b09cbbtk1#
您可以将Spring Security配置为使用自定义的
AuthenticationEntryPoint
,如下所示:这样,SpringSecurity将基于
RequestMatcher#matches
方法获取AuthenticationEntryPoint