【发布时间】:2016-11-03 11:44:36
【问题描述】:
我使用 Spring Security 的 WebSecurityConfig 来管理权限。
并且权限只在 spring 应用程序启动时加载一次。
那么当权限改变时,如何在运行时手动重新加载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-security spring-boot