小编Mat*_*see的帖子

在运行时配置Spring HTTP安全性

启动时应用所有http安全性:

protected void configure(HttpSecurity http) throws Exception {
    http
        .authorizeRequests()
        .antMatchers("/admin/**").hasRole("admin")
}
Run Code Online (Sandbox Code Playgroud)

在运行时,我正在尝试添加更多...

applicationContext.getBean(WebSecurityConfigurerAdapter).http.authorizeRequests().antMatchers("bla").hasRole("admin")
Run Code Online (Sandbox Code Playgroud)

当执行该行时,它会将其添加到http.authorizeRequests(),但/ bla仍可由"非管理员"访问

重新启动服务器时,此更改将生效,因为它正在从数据库加载bla.

如何在不重新启动服务器的情况下立即使安全性生效?

spring spring-security

6
推荐指数
1
解决办法
1286
查看次数

标签 统计

spring ×1

spring-security ×1