我怎么能重新加载websecurityconfig运行时

zig*_*ear 6 spring-security spring-boot

我使用Spring Security 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);
    }

}
Run Code Online (Sandbox Code Playgroud)

Ste*_*com 0

只需将您需要的任何内容注入 WebSecurityConfig 即可。您可以在 WebSecurityConfig 中使用 @Autowire 和 @Value。