我已經使用Spring Security的WebSecurityConfig
來管理權限。 和剛剛加載一次Spring應用程序啓動時的權限。我該如何重新加載websecurityconfig運行時
如何在運行時手動重新加載WebSecurityConfig
權限被更改?
這是我WebSecurityConfig
代碼:
@Configuration
@EnableWebSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter
{
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.antMatchers("/css/**").permitAll()
.antMatchers("/js/**").permitAll()
.antMatchers("/rest/login").permitAll()
.anyRequest().authenticated()
.and()
.formLogin()
.loginPage("/boss/login")
.permitAll()
.and()
.logout()
.permitAll();
http.csrf().disable();
}
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
auth.authenticationProvider(authProvider);
}
}
我有同樣的問題(我需要Spring Boot來識別應用程序啓動後添加的用戶,並且它似乎只在啓動時才執行一次,並且從未再次運行)。你能舉個例子嗎?你如何從一個單獨的控制登錄頁面調用configureGlobal()?像這裏的GreetingController.java示例: https://spring.io/guides/gs/serving-web-content/ –