Я использую весеннюю загрузку, а в весенней безопасности мы используем "WebSecurityConfigurerAdapter" и используем метод
@Override
protected void configure(HttpSecurity http) throws Exception {
AuthenticationFilter authenticationFilter = new AuthenticationFilter(authenticationManager(), tokenService(), externalServiceAuthenticator());
http.addFilterBefore(authenticationFilter, BasicAuthenticationFilter.class)
.csrf().disable()
.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS)
.and().authorizeRequests().antMatchers(externalServiceCaller.getPrivateEndPoints())
.hasAnyAuthority(externalServiceCaller.getAllAuthorities()).anyRequest().authenticated()
.and().authorizeRequests().anyRequest().anonymous()
.and().exceptionHandling().authenticationEntryPoint(unauthorizedEntryPoint())
.and().exceptionHandling().authenticationEntryPoint(forbiddenEntryPoint());
}
Это хорошо работает для существующей роли и пользователя, но когда мы добавляем больше пользователей и роль ввремя выполнения (после запуска приложения), то Spring Security не может распознать новую роль и нового пользователя.Есть ли способ вызвать вышеупомянутый метод снова, когда приложение запущено и работает.