Я использую весеннюю безопасность через весеннюю загрузку. У меня два вида отдыха.
public/** --> Каждый может получить доступ к этим сервисам и использовать их
secure/** --> Только авторизованные пользователи могут использовать.
@Slf4j
@Configuration
@EnableWebSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
@Override
public void configure(WebSecurity webSecurity) throws Exception {
webSecurity.ignoring().antMatchers("/public/**");
}
@Override
protected void configure(HttpSecurity http) throws Exception {
http.addFilterBefore(requestHeaderAuthenticationFilter(authenticationManager()),
BasicAuthenticationFilter.class)
.authorizeRequests().antMatchers("/secure/**").fullyAuthenticated();
}
@Bean
public RequestHeaderAuthenticationFilter requestHeaderAuthenticationFilter(
final AuthenticationManager authenticationManager) {
RequestHeaderAuthenticationFilter filter = new RequestHeaderAuthenticationFilter();
filter.setAuthenticationManager(authenticationManager);
filter.setExceptionIfHeaderMissing(true);
filter.setPrincipalRequestHeader("MY_HEADER");
filter.setInvalidateSessionOnPrincipalChange(true);
filter.setCheckForPrincipalChanges(false);
filter.setContinueFilterChainOnUnsuccessfulAuthentication(false);
return filter;
}
Когда я хочу получить доступ к общедоступному ресурсу, я получил исключение.
исключение: "org.springframework.security.web.authentication.preauth.PreAuthenticatedCredentialsNotFoundException"
сообщение: «Заголовок MY_HEADER не найден в запросе».
Почему мой фильтр активируется на общедоступном ресурсе, хотя он настроен как игнорируемый ресурс?
Спасибо заранее