|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+package com.ruoyi.common.security.config;
|
|
|
2
|
+
|
|
|
3
|
+import org.springframework.context.annotation.Configuration;
|
|
|
4
|
+import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
|
|
|
5
|
+
|
|
|
6
|
+/**
|
|
|
7
|
+ *
|
|
|
8
|
+ * @EnableGlobalMethodSecurity(securedEnabled=true)
|
|
|
9
|
+ * 开启@Secured 注解过滤权限
|
|
|
10
|
+ *
|
|
|
11
|
+ * @EnableGlobalMethodSecurity(jsr250Enabled=true)
|
|
|
12
|
+ * 开启@RolesAllowed 注解过滤权限
|
|
|
13
|
+ *
|
|
|
14
|
+ * @EnableGlobalMethodSecurity(prePostEnabled=true)
|
|
|
15
|
+ * 使用表达式时间方法级别的安全性 4个注解可用
|
|
|
16
|
+ * -@PreAuthorize 在方法调用之前,基于表达式的计算结果来限制对方法的访问
|
|
|
17
|
+ * -@PostAuthorize 允许方法调用,但是如果表达式计算结果为false,将抛出一个安全性异常
|
|
|
18
|
+ * -@PostFilter 允许方法调用,但必须按照表达式来过滤方法的结果
|
|
|
19
|
+ * -@PreFilter 允许方法调用,但必须在进入方法之前过滤输入值
|
|
|
20
|
+ *
|
|
|
21
|
+ */
|
|
|
22
|
+@Configuration
|
|
|
23
|
+@EnableGlobalMethodSecurity(prePostEnabled = true)
|
|
|
24
|
+public class MethodSecurityConfig
|
|
|
25
|
+{
|
|
|
26
|
+
|
|
|
27
|
+}
|