我怎么能重新加载 websecurityconfig 运行时 [英] how could I reload websecurityconfig runtime

查看:29
本文介绍了我怎么能重新加载 websecurityconfig 运行时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 Spring Security 的 WebSecurityConfig 来管理权限.和权限只在 spring 应用程序启动时加载一次.

I've use Spring Security's WebSecurityConfig to manager permissions. and permissions just loaded once when the spring application started.

那么当权限改变时,我怎么能在运行时手动重新加载WebSecurityConfig?

so how could I manually reload WebSecurityConfig in runtime when permission is changed?

这是我的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);
    }

}

推荐答案

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

Just get injected into WebSecurityConfig whatever you need. You can use @Autowire and @Value inside the WebSecurityConfig.

这篇关于我怎么能重新加载 websecurityconfig 运行时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆