这里写自定义目录标题
记录一下今天的一个收获 动态开启权限注解
通过配置开启或者关闭security 权限控制开关
How to disable/ ignore @PreAuthorize in a Spring Boot application
如何在 Spring Boot 应用程序中禁用/忽略 @PreAuthorize
/**
* 读取配置文件 true为开启@PreAuthorize注解 false为不开启注解
*/
@ConditionalOnProperty(prefix = "security",
name = "enabled",
havingValue = "true")
@EnableGlobalMethodSecurity(prePostEnabled = true)
static class SecurityEnabledFlag {
}
如果security.enabled=false,Dummy bean 将不会被创建,因此@EnableGlobalMethodSecurity(prePostEnabled = true) 也将不存在,最后@PreAuthorize 注释将被忽略。