Преглед изворни кода

移除 OAuth2 改为 Redis

RuoYi пре 5 година
родитељ
комит
6704db8108
83 измењених фајлова са 1244 додато и 2533 уклоњено
  1. 1 1
      README.md
  2. 2 2
      ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/RemoteUserService.java
  3. 2 2
      ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/factory/RemoteUserFallbackFactory.java
  4. 135 0
      ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/model/LoginUser.java
  5. 0 60
      ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/model/UserInfo.java
  6. 9 9
      ruoyi-auth/pom.xml
  7. 0 131
      ruoyi-auth/src/main/java/com/ruoyi/auth/config/AuthServerConfig.java
  8. 0 59
      ruoyi-auth/src/main/java/com/ruoyi/auth/config/WebSecurityConfig.java
  9. 35 34
      ruoyi-auth/src/main/java/com/ruoyi/auth/controller/TokenController.java
  10. 0 21
      ruoyi-auth/src/main/java/com/ruoyi/auth/controller/UserController.java
  11. 0 20
      ruoyi-auth/src/main/java/com/ruoyi/auth/exception/CustomOauthException.java
  12. 0 48
      ruoyi-auth/src/main/java/com/ruoyi/auth/exception/CustomOauthExceptionSerializer.java
  13. 0 20
      ruoyi-auth/src/main/java/com/ruoyi/auth/exception/CustomWebResponseExceptionTranslator.java
  14. 69 0
      ruoyi-auth/src/main/java/com/ruoyi/auth/form/LoginBody.java
  15. 0 39
      ruoyi-auth/src/main/java/com/ruoyi/auth/handler/AuthenticationSuccessEventHandler.java
  16. 89 0
      ruoyi-auth/src/main/java/com/ruoyi/auth/service/SysLoginService.java
  17. 19 4
      ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/constant/CacheConstants.java
  18. 6 1
      ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/constant/Constants.java
  19. 0 56
      ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/constant/SecurityConstants.java
  20. 15 0
      ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/constant/UserConstants.java
  21. 15 0
      ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/exception/PreAuthorizeException.java
  22. 4 4
      ruoyi-common/ruoyi-common-datascope/src/main/java/com/ruoyi/common/datascope/aspect/DataScopeAspect.java
  23. 0 42
      ruoyi-common/ruoyi-common-datascope/src/main/java/com/ruoyi/common/datascope/service/AwaitUserService.java
  24. 0 1
      ruoyi-common/ruoyi-common-datascope/src/main/resources/META-INF/spring.factories
  25. 5 14
      ruoyi-common/ruoyi-common-log/src/main/java/com/ruoyi/common/log/aspect/LogAspect.java
  26. 1 1
      ruoyi-common/ruoyi-common-redis/src/main/java/com/ruoyi/common/redis/service/RedisService.java
  27. 5 5
      ruoyi-common/ruoyi-common-security/pom.xml
  28. 1 3
      ruoyi-common/ruoyi-common-security/src/main/java/com/ruoyi/common/security/annotation/EnableCustomConfig.java
  29. 46 0
      ruoyi-common/ruoyi-common-security/src/main/java/com/ruoyi/common/security/annotation/PreAuthorize.java
  30. 195 0
      ruoyi-common/ruoyi-common-security/src/main/java/com/ruoyi/common/security/aspect/PreAuthorizeAspect.java
  31. 0 30
      ruoyi-common/ruoyi-common-security/src/main/java/com/ruoyi/common/security/config/AuthIgnoreConfig.java
  32. 0 75
      ruoyi-common/ruoyi-common-security/src/main/java/com/ruoyi/common/security/config/CommonUserConverter.java
  33. 0 27
      ruoyi-common/ruoyi-common-security/src/main/java/com/ruoyi/common/security/config/MethodSecurityConfig.java
  34. 0 82
      ruoyi-common/ruoyi-common-security/src/main/java/com/ruoyi/common/security/config/ResourceServerConfig.java
  35. 0 24
      ruoyi-common/ruoyi-common-security/src/main/java/com/ruoyi/common/security/config/SecurityImportBeanDefinitionRegistrar.java
  36. 0 37
      ruoyi-common/ruoyi-common-security/src/main/java/com/ruoyi/common/security/domain/LoginUser.java
  37. 0 20
      ruoyi-common/ruoyi-common-security/src/main/java/com/ruoyi/common/security/feign/OAuth2FeignConfig.java
  38. 0 33
      ruoyi-common/ruoyi-common-security/src/main/java/com/ruoyi/common/security/feign/OAuth2FeignRequestInterceptor.java
  39. 0 33
      ruoyi-common/ruoyi-common-security/src/main/java/com/ruoyi/common/security/handler/CustomAccessDeniedHandler.java
  40. 11 34
      ruoyi-common/ruoyi-common-security/src/main/java/com/ruoyi/common/security/handler/GlobalExceptionHandler.java
  41. 0 167
      ruoyi-common/ruoyi-common-security/src/main/java/com/ruoyi/common/security/service/PermissionService.java
  42. 0 30
      ruoyi-common/ruoyi-common-security/src/main/java/com/ruoyi/common/security/service/RedisClientDetailsService.java
  43. 123 0
      ruoyi-common/ruoyi-common-security/src/main/java/com/ruoyi/common/security/service/TokenService.java
  44. 0 83
      ruoyi-common/ruoyi-common-security/src/main/java/com/ruoyi/common/security/service/UserDetailsServiceImpl.java
  45. 13 39
      ruoyi-common/ruoyi-common-security/src/main/java/com/ruoyi/common/security/utils/SecurityUtils.java
  46. 2 6
      ruoyi-common/ruoyi-common-security/src/main/resources/META-INF/spring.factories
  47. 35 38
      ruoyi-common/ruoyi-common-swagger/src/main/java/com/ruoyi/common/swagger/config/SwaggerAutoConfiguration.java
  48. 108 0
      ruoyi-gateway/src/main/java/com/ruoyi/gateway/filter/AuthFilter.java
  49. 100 0
      ruoyi-gateway/src/main/java/com/ruoyi/gateway/filter/CacheRequestFilter.java
  50. 24 24
      ruoyi-gateway/src/main/java/com/ruoyi/gateway/filter/ValidateCodeFilter.java
  51. 2 2
      ruoyi-modules/ruoyi-gen/pom.xml
  52. 11 12
      ruoyi-modules/ruoyi-gen/src/main/java/com/ruoyi/gen/controller/GenController.java
  53. 7 7
      ruoyi-modules/ruoyi-gen/src/main/resources/vm/java/controller.java.vm
  54. 2 2
      ruoyi-modules/ruoyi-job/pom.xml
  55. 9 9
      ruoyi-modules/ruoyi-job/src/main/java/com/ruoyi/job/controller/SysJobController.java
  56. 6 6
      ruoyi-modules/ruoyi-job/src/main/java/com/ruoyi/job/controller/SysJobLogController.java
  57. 2 2
      ruoyi-modules/ruoyi-system/pom.xml
  58. 0 94
      ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysClientDetailsController.java
  59. 7 7
      ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysConfigController.java
  60. 7 9
      ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysDeptController.java
  61. 7 7
      ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysDictDataController.java
  62. 8 8
      ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysDictTypeController.java
  63. 5 5
      ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysLogininforController.java
  64. 10 14
      ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysMenuController.java
  65. 6 6
      ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysNoticeController.java
  66. 5 5
      ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysOperlogController.java
  67. 7 7
      ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysPostController.java
  68. 10 10
      ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysRoleController.java
  69. 14 14
      ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysUserController.java
  70. 0 213
      ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysClientDetails.java
  71. 0 60
      ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysClientDetailsMapper.java
  72. 0 52
      ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysClientDetailsService.java
  73. 0 87
      ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysClientDetailsServiceImpl.java
  74. 0 99
      ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SysClientDetailsMapper.xml
  75. 6 9
      ruoyi-ui/src/api/login.js
  76. 0 44
      ruoyi-ui/src/api/system/client.js
  77. 10 19
      ruoyi-ui/src/store/modules/user.js
  78. 0 14
      ruoyi-ui/src/utils/auth.js
  79. 1 1
      ruoyi-ui/src/utils/request.js
  80. 1 1
      ruoyi-ui/src/views/index.vue
  81. 0 292
      ruoyi-ui/src/views/system/client/index.vue
  82. 28 54
      sql/ry_20200823.sql
  83. 3 3
      sql/ry_config_20200618.sql

+ 1 - 1
README.md

@@ -2,7 +2,7 @@
2 2
 
3 3
 * 采用前后端分离的模式,微服务版本前端(基于 [RuoYi-Vue](https://gitee.com/y_project/RuoYi-Vue))。
4 4
 * 后端采用Spring Boot、Spring Cloud & Alibaba。
5
-* 注册中心、配置中心选型Nacos,权限认证使用OAuth2
5
+* 注册中心、配置中心选型Nacos,权限认证使用Redis
6 6
 * 流量控制框架选型Sentinel。
7 7
 * 如需不分离应用,请移步 [RuoYi](https://gitee.com/y_project/RuoYi),如需分离应用,请移步 [RuoYi-Vue](https://gitee.com/y_project/RuoYi-Vue)
8 8
 * 阿里云优惠券:[点我进入](https://www.aliyun.com/minisite/goods?userCode=brki8iof&share_source=copy_link),腾讯云优惠券:[点我领取](https://cloud.tencent.com/redirect.php?redirect=1025&cps_key=198c8df2ed259157187173bc7f4f32fd&from=console)  

+ 2 - 2
ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/RemoteUserService.java

@@ -6,7 +6,7 @@ import org.springframework.web.bind.annotation.PathVariable;
6 6
 import com.ruoyi.common.core.constant.ServiceNameConstants;
7 7
 import com.ruoyi.common.core.domain.R;
8 8
 import com.ruoyi.system.api.factory.RemoteUserFallbackFactory;
9
-import com.ruoyi.system.api.model.UserInfo;
9
+import com.ruoyi.system.api.model.LoginUser;
10 10
 
11 11
 /**
12 12
  * 用户服务
@@ -23,5 +23,5 @@ public interface RemoteUserService
23 23
      * @return 结果
24 24
      */
25 25
     @GetMapping(value = "/user/info/{username}")
26
-    public R<UserInfo> getUserInfo(@PathVariable("username") String username);
26
+    public R<LoginUser> getUserInfo(@PathVariable("username") String username);
27 27
 }

+ 2 - 2
ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/factory/RemoteUserFallbackFactory.java

@@ -5,7 +5,7 @@ import org.slf4j.LoggerFactory;
5 5
 import org.springframework.stereotype.Component;
6 6
 import com.ruoyi.common.core.domain.R;
7 7
 import com.ruoyi.system.api.RemoteUserService;
8
-import com.ruoyi.system.api.model.UserInfo;
8
+import com.ruoyi.system.api.model.LoginUser;
9 9
 import feign.hystrix.FallbackFactory;
10 10
 
11 11
 /**
@@ -25,7 +25,7 @@ public class RemoteUserFallbackFactory implements FallbackFactory<RemoteUserServ
25 25
         return new RemoteUserService()
26 26
         {
27 27
             @Override
28
-            public R<UserInfo> getUserInfo(String username)
28
+            public R<LoginUser> getUserInfo(String username)
29 29
             {
30 30
                 return null;
31 31
             }

+ 135 - 0
ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/model/LoginUser.java

@@ -0,0 +1,135 @@
1
+package com.ruoyi.system.api.model;
2
+
3
+import java.io.Serializable;
4
+import java.util.Set;
5
+import com.ruoyi.system.api.domain.SysUser;
6
+
7
+/**
8
+ * 用户信息
9
+ *
10
+ * @author ruoyi
11
+ */
12
+public class LoginUser implements Serializable
13
+{
14
+    private static final long serialVersionUID = 1L;
15
+
16
+    /**
17
+     * 用户唯一标识
18
+     */
19
+    private String token;
20
+
21
+    /**
22
+     * 用户名id
23
+     */
24
+    private Long userid;
25
+
26
+    /**
27
+     * 用户名
28
+     */
29
+    private String username;
30
+
31
+    /**
32
+     * 登陆时间
33
+     */
34
+    private Long loginTime;
35
+
36
+    /**
37
+     * 过期时间
38
+     */
39
+    private Long expireTime;
40
+
41
+    /**
42
+     * 权限列表
43
+     */
44
+    private Set<String> permissions;
45
+
46
+    /**
47
+     * 角色列表
48
+     */
49
+    private Set<String> roles;
50
+
51
+    /**
52
+     * 用户信息
53
+     */
54
+    private SysUser sysUser;
55
+
56
+    public String getToken()
57
+    {
58
+        return token;
59
+    }
60
+
61
+    public void setToken(String token)
62
+    {
63
+        this.token = token;
64
+    }
65
+
66
+    public Long getUserid()
67
+    {
68
+        return userid;
69
+    }
70
+
71
+    public void setUserid(Long userid)
72
+    {
73
+        this.userid = userid;
74
+    }
75
+
76
+    public String getUsername()
77
+    {
78
+        return username;
79
+    }
80
+
81
+    public void setUsername(String username)
82
+    {
83
+        this.username = username;
84
+    }
85
+
86
+    public Long getLoginTime()
87
+    {
88
+        return loginTime;
89
+    }
90
+
91
+    public void setLoginTime(Long loginTime)
92
+    {
93
+        this.loginTime = loginTime;
94
+    }
95
+
96
+    public Long getExpireTime()
97
+    {
98
+        return expireTime;
99
+    }
100
+
101
+    public void setExpireTime(Long expireTime)
102
+    {
103
+        this.expireTime = expireTime;
104
+    }
105
+
106
+    public Set<String> getPermissions()
107
+    {
108
+        return permissions;
109
+    }
110
+
111
+    public void setPermissions(Set<String> permissions)
112
+    {
113
+        this.permissions = permissions;
114
+    }
115
+
116
+    public Set<String> getRoles()
117
+    {
118
+        return roles;
119
+    }
120
+
121
+    public void setRoles(Set<String> roles)
122
+    {
123
+        this.roles = roles;
124
+    }
125
+
126
+    public SysUser getSysUser()
127
+    {
128
+        return sysUser;
129
+    }
130
+
131
+    public void setSysUser(SysUser sysUser)
132
+    {
133
+        this.sysUser = sysUser;
134
+    }
135
+}

+ 0 - 60
ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/model/UserInfo.java

@@ -1,60 +0,0 @@
1
-package com.ruoyi.system.api.model;
2
-
3
-import java.io.Serializable;
4
-import java.util.Set;
5
-import com.ruoyi.system.api.domain.SysUser;
6
-
7
-/**
8
- * 用户信息
9
- *
10
- * @author ruoyi
11
- */
12
-public class UserInfo implements Serializable
13
-{
14
-    private static final long serialVersionUID = 1L;
15
-
16
-    /**
17
-     * 用户基本信息
18
-     */
19
-    private SysUser sysUser;
20
-
21
-    /**
22
-     * 权限标识集合
23
-     */
24
-    private Set<String> permissions;
25
-
26
-    /**
27
-     * 角色集合
28
-     */
29
-    private Set<String> roles;
30
-
31
-    public SysUser getSysUser()
32
-    {
33
-        return sysUser;
34
-    }
35
-
36
-    public void setSysUser(SysUser sysUser)
37
-    {
38
-        this.sysUser = sysUser;
39
-    }
40
-
41
-    public Set<String> getPermissions()
42
-    {
43
-        return permissions;
44
-    }
45
-
46
-    public void setPermissions(Set<String> permissions)
47
-    {
48
-        this.permissions = permissions;
49
-    }
50
-
51
-    public Set<String> getRoles()
52
-    {
53
-        return roles;
54
-    }
55
-
56
-    public void setRoles(Set<String> roles)
57
-    {
58
-        this.roles = roles;
59
-    }
60
-}

+ 9 - 9
ruoyi-auth/pom.xml

@@ -28,10 +28,10 @@
28 28
             <artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
29 29
         </dependency>
30 30
         
31
-        <!-- SpringCloud Netflix Hystrix -->
31
+        <!-- SpringCloud Ailibaba Sentinel -->
32 32
         <dependency>
33
-            <groupId>org.springframework.cloud</groupId>
34
-            <artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
33
+            <groupId>com.alibaba.cloud</groupId>
34
+            <artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
35 35
         </dependency>
36 36
 		
37 37
         <!-- SpringBoot Web -->
@@ -40,6 +40,12 @@
40 40
             <artifactId>spring-boot-starter-web</artifactId>
41 41
         </dependency>
42 42
         
43
+        <!-- SpringBoot Actuator -->
44
+        <dependency>
45
+            <groupId>org.springframework.boot</groupId>
46
+            <artifactId>spring-boot-starter-actuator</artifactId>
47
+        </dependency>
48
+        
43 49
         <!-- Mysql Connector -->
44 50
         <dependency>
45 51
             <groupId>mysql</groupId>
@@ -52,12 +58,6 @@
52 58
             <artifactId>ruoyi-common-security</artifactId>
53 59
         </dependency>
54 60
         
55
-        <!-- RuoYi Common Redis-->
56
-        <dependency>
57
-            <groupId>com.ruoyi</groupId>
58
-            <artifactId>ruoyi-common-redis</artifactId>
59
-        </dependency>
60
-        
61 61
     </dependencies>
62 62
 	
63 63
     <build>

+ 0 - 131
ruoyi-auth/src/main/java/com/ruoyi/auth/config/AuthServerConfig.java

@@ -1,131 +0,0 @@
1
-package com.ruoyi.auth.config;
2
-
3
-import java.util.LinkedHashMap;
4
-import java.util.Map;
5
-import javax.sql.DataSource;
6
-import org.springframework.beans.factory.annotation.Autowired;
7
-import org.springframework.context.annotation.Bean;
8
-import org.springframework.context.annotation.Configuration;
9
-import org.springframework.data.redis.connection.RedisConnectionFactory;
10
-import org.springframework.http.HttpMethod;
11
-import org.springframework.security.authentication.AuthenticationManager;
12
-import org.springframework.security.core.userdetails.UserDetailsService;
13
-import org.springframework.security.oauth2.common.DefaultOAuth2AccessToken;
14
-import org.springframework.security.oauth2.config.annotation.configurers.ClientDetailsServiceConfigurer;
15
-import org.springframework.security.oauth2.config.annotation.web.configuration.AuthorizationServerConfigurerAdapter;
16
-import org.springframework.security.oauth2.config.annotation.web.configuration.EnableAuthorizationServer;
17
-import org.springframework.security.oauth2.config.annotation.web.configurers.AuthorizationServerEndpointsConfigurer;
18
-import org.springframework.security.oauth2.config.annotation.web.configurers.AuthorizationServerSecurityConfigurer;
19
-import org.springframework.security.oauth2.provider.token.TokenEnhancer;
20
-import org.springframework.security.oauth2.provider.token.TokenStore;
21
-import org.springframework.security.oauth2.provider.token.store.redis.RedisTokenStore;
22
-import com.ruoyi.auth.exception.CustomWebResponseExceptionTranslator;
23
-import com.ruoyi.common.core.constant.CacheConstants;
24
-import com.ruoyi.common.core.constant.SecurityConstants;
25
-import com.ruoyi.common.security.domain.LoginUser;
26
-import com.ruoyi.common.security.service.RedisClientDetailsService;
27
-
28
-/**
29
- * OAuth2 认证服务配置
30
- * 
31
- * @author ruoyi
32
- */
33
-@Configuration
34
-@EnableAuthorizationServer
35
-public class AuthServerConfig extends AuthorizationServerConfigurerAdapter
36
-{
37
-    @Autowired
38
-    private AuthenticationManager authenticationManager;
39
-
40
-    @Autowired
41
-    private DataSource dataSource;
42
-
43
-    @Autowired
44
-    private RedisConnectionFactory redisConnectionFactory;
45
-
46
-    @Autowired
47
-    private UserDetailsService userDetailsService;
48
-
49
-    @Autowired
50
-    private TokenEnhancer tokenEnhancer;
51
-
52
-    /**
53
-     * 定义授权和令牌端点以及令牌服务
54
-     */
55
-    @Override
56
-    public void configure(AuthorizationServerEndpointsConfigurer endpoints)
57
-    {
58
-        endpoints
59
-                // 请求方式
60
-                .allowedTokenEndpointRequestMethods(HttpMethod.GET, HttpMethod.POST)
61
-                // 指定token存储位置
62
-                .tokenStore(tokenStore())
63
-                // 自定义生成令牌
64
-                .tokenEnhancer(tokenEnhancer)
65
-                // 用户账号密码认证
66
-                .userDetailsService(userDetailsService)
67
-                // 指定认证管理器
68
-                .authenticationManager(authenticationManager)
69
-                // 是否重复使用 refresh_token
70
-                .reuseRefreshTokens(false)
71
-                // 自定义异常处理
72
-                .exceptionTranslator(new CustomWebResponseExceptionTranslator());
73
-    }
74
-
75
-    /**
76
-     * 配置令牌端点(Token Endpoint)的安全约束
77
-     */
78
-    @Override
79
-    public void configure(AuthorizationServerSecurityConfigurer oauthServer)
80
-    {
81
-        oauthServer.allowFormAuthenticationForClients().checkTokenAccess("permitAll()");
82
-    }
83
-
84
-    /**
85
-     * 声明 ClientDetails实现
86
-     */
87
-    public RedisClientDetailsService clientDetailsService()
88
-    {
89
-        RedisClientDetailsService clientDetailsService = new RedisClientDetailsService(dataSource);
90
-        return clientDetailsService;
91
-    }
92
-
93
-    /**
94
-     * 配置客户端详情
95
-     */
96
-    @Override
97
-    public void configure(ClientDetailsServiceConfigurer clients) throws Exception
98
-    {
99
-        clients.withClientDetails(clientDetailsService());
100
-    }
101
-
102
-    /**
103
-     * 基于 Redis 实现,令牌保存到缓存
104
-     */
105
-    @Bean
106
-    public TokenStore tokenStore()
107
-    {
108
-        RedisTokenStore tokenStore = new RedisTokenStore(redisConnectionFactory);
109
-        tokenStore.setPrefix(CacheConstants.OAUTH_ACCESS);
110
-        return tokenStore;
111
-    }
112
-
113
-    /**
114
-     * 自定义生成令牌
115
-     */
116
-    @Bean
117
-    public TokenEnhancer tokenEnhancer()
118
-    {
119
-        return (accessToken, authentication) -> {
120
-            if (authentication.getUserAuthentication() != null)
121
-            {
122
-                Map<String, Object> additionalInformation = new LinkedHashMap<String, Object>();
123
-                LoginUser user = (LoginUser) authentication.getUserAuthentication().getPrincipal();
124
-                additionalInformation.put(SecurityConstants.DETAILS_USER_ID, user.getUserId());
125
-                additionalInformation.put(SecurityConstants.DETAILS_USERNAME, user.getUsername());
126
-                ((DefaultOAuth2AccessToken) accessToken).setAdditionalInformation(additionalInformation);
127
-            }
128
-            return accessToken;
129
-        };
130
-    }
131
-}

+ 0 - 59
ruoyi-auth/src/main/java/com/ruoyi/auth/config/WebSecurityConfig.java

@@ -1,59 +0,0 @@
1
-package com.ruoyi.auth.config;
2
-
3
-import org.springframework.beans.factory.annotation.Autowired;
4
-import org.springframework.context.annotation.Bean;
5
-import org.springframework.context.annotation.Configuration;
6
-import org.springframework.core.annotation.Order;
7
-import org.springframework.security.authentication.AuthenticationManager;
8
-import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
9
-import org.springframework.security.config.annotation.web.builders.HttpSecurity;
10
-import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
11
-import org.springframework.security.core.userdetails.UserDetailsService;
12
-import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
13
-import org.springframework.security.crypto.password.PasswordEncoder;
14
-
15
-/**
16
- * Security 安全认证相关配置
17
- * Oauth2依赖于Security 默认情况下WebSecurityConfig执行比ResourceServerConfig优先
18
- * 
19
- * @author ruoyi
20
- */
21
-@Order(99)
22
-@Configuration
23
-public class WebSecurityConfig extends WebSecurityConfigurerAdapter
24
-{
25
-    @Autowired
26
-    private UserDetailsService userDetailsService;
27
-
28
-    @Bean
29
-    public PasswordEncoder passwordEncoder()
30
-    {
31
-        return new BCryptPasswordEncoder();
32
-    }
33
-
34
-    @Bean
35
-    @Override
36
-    public AuthenticationManager authenticationManagerBean() throws Exception
37
-    {
38
-        return super.authenticationManagerBean();
39
-    }
40
-
41
-    @Override
42
-    protected void configure(AuthenticationManagerBuilder auth) throws Exception
43
-    {
44
-        auth.userDetailsService(userDetailsService).passwordEncoder(passwordEncoder());
45
-    }
46
-
47
-    @Override
48
-    protected void configure(HttpSecurity http) throws Exception
49
-    {
50
-        http
51
-        .authorizeRequests()
52
-        .antMatchers(
53
-            "/actuator/**",
54
-            "/oauth/*",
55
-            "/token/**").permitAll()
56
-        .anyRequest().authenticated()
57
-        .and().csrf().disable();
58
-    }
59
-}

+ 35 - 34
ruoyi-auth/src/main/java/com/ruoyi/auth/controller/TokenController.java

@@ -1,20 +1,17 @@
1 1
 package com.ruoyi.auth.controller;
2 2
 
3
-import java.util.Map;
3
+import javax.servlet.http.HttpServletRequest;
4 4
 import org.springframework.beans.factory.annotation.Autowired;
5
-import org.springframework.http.HttpHeaders;
6
-import org.springframework.security.oauth2.common.OAuth2AccessToken;
7
-import org.springframework.security.oauth2.common.OAuth2RefreshToken;
8
-import org.springframework.security.oauth2.provider.token.TokenStore;
9 5
 import org.springframework.web.bind.annotation.DeleteMapping;
10
-import org.springframework.web.bind.annotation.RequestHeader;
11
-import org.springframework.web.bind.annotation.RequestMapping;
6
+import org.springframework.web.bind.annotation.PostMapping;
7
+import org.springframework.web.bind.annotation.RequestBody;
12 8
 import org.springframework.web.bind.annotation.RestController;
13
-import com.ruoyi.common.core.constant.Constants;
14
-import com.ruoyi.common.core.constant.SecurityConstants;
9
+import com.ruoyi.auth.form.LoginBody;
10
+import com.ruoyi.auth.service.SysLoginService;
15 11
 import com.ruoyi.common.core.domain.R;
16 12
 import com.ruoyi.common.core.utils.StringUtils;
17
-import com.ruoyi.system.api.RemoteLogService;
13
+import com.ruoyi.common.security.service.TokenService;
14
+import com.ruoyi.system.api.model.LoginUser;
18 15
 
19 16
 /**
20 17
  * token 控制
@@ -22,42 +19,46 @@ import com.ruoyi.system.api.RemoteLogService;
22 19
  * @author ruoyi
23 20
  */
24 21
 @RestController
25
-@RequestMapping("/token")
26 22
 public class TokenController
27 23
 {
28 24
     @Autowired
29
-    private TokenStore tokenStore;
25
+    private TokenService tokenService;
30 26
 
31 27
     @Autowired
32
-    private RemoteLogService remoteLogService;
28
+    private SysLoginService sysLoginService;
33 29
 
34
-    @DeleteMapping("/logout")
35
-    public R<?> logout(@RequestHeader(value = HttpHeaders.AUTHORIZATION, required = false) String authHeader)
30
+    @PostMapping("login")
31
+    public R<?> login(@RequestBody LoginBody form)
36 32
     {
37
-        if (StringUtils.isEmpty(authHeader))
38
-        {
39
-            return R.ok();
40
-        }
33
+        // 用户登录
34
+        LoginUser userInfo = sysLoginService.login(form.getUsername(), form.getPassword());
35
+        // 获取登录token
36
+        return R.ok(tokenService.createToken(userInfo));
37
+    }
41 38
 
42
-        String tokenValue = authHeader.replace(OAuth2AccessToken.BEARER_TYPE, StringUtils.EMPTY).trim();
43
-        OAuth2AccessToken accessToken = tokenStore.readAccessToken(tokenValue);
44
-        if (accessToken == null || StringUtils.isEmpty(accessToken.getValue()))
39
+    @DeleteMapping("logout")
40
+    public R<?> logout(HttpServletRequest request)
41
+    {
42
+        LoginUser loginUser = tokenService.getLoginUser(request);
43
+        if (StringUtils.isNotNull(loginUser))
45 44
         {
46
-            return R.ok();
45
+            String username = loginUser.getUsername();
46
+            // 删除用户缓存记录
47
+            tokenService.delLoginUser(loginUser.getToken());
48
+            // 记录用户退出日志
49
+            sysLoginService.logout(username);
47 50
         }
51
+        return R.ok();
52
+    }
48 53
 
49
-        // 清空 access token
50
-        tokenStore.removeAccessToken(accessToken);
51
-
52
-        // 清空 refresh token
53
-        OAuth2RefreshToken refreshToken = accessToken.getRefreshToken();
54
-        tokenStore.removeRefreshToken(refreshToken);
55
-        Map<String, ?> map = accessToken.getAdditionalInformation();
56
-        if (map.containsKey(SecurityConstants.DETAILS_USERNAME))
54
+    @PostMapping("refresh")
55
+    public R<?> refresh(HttpServletRequest request)
56
+    {
57
+        LoginUser loginUser = tokenService.getLoginUser(request);
58
+        if (StringUtils.isNotNull(loginUser))
57 59
         {
58
-            String username = (String) map.get(SecurityConstants.DETAILS_USERNAME);
59
-            // 记录用户退出日志
60
-            remoteLogService.saveLogininfor(username, Constants.LOGOUT, "退出成功");
60
+            // 刷新令牌有效期
61
+            return R.ok(tokenService.refreshToken(loginUser));
61 62
         }
62 63
         return R.ok();
63 64
     }

+ 0 - 21
ruoyi-auth/src/main/java/com/ruoyi/auth/controller/UserController.java

@@ -1,21 +0,0 @@
1
-package com.ruoyi.auth.controller;
2
-
3
-import java.security.Principal;
4
-import org.springframework.web.bind.annotation.RequestMapping;
5
-import org.springframework.web.bind.annotation.RestController;
6
-
7
-/**
8
- * 身份信息获取
9
- * 
10
- * @author ruoyi
11
- */
12
-@RestController
13
-@RequestMapping("/oauth")
14
-public class UserController
15
-{
16
-    @RequestMapping("/user")
17
-    public Principal user(Principal user)
18
-    {
19
-        return user;
20
-    }
21
-}

+ 0 - 20
ruoyi-auth/src/main/java/com/ruoyi/auth/exception/CustomOauthException.java

@@ -1,20 +0,0 @@
1
-package com.ruoyi.auth.exception;
2
-
3
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
4
-import org.springframework.security.oauth2.common.exceptions.OAuth2Exception;
5
-
6
-/**
7
- * oauth2自定义异常
8
- *
9
- * @author ruoyi
10
- **/
11
-@JsonSerialize(using = CustomOauthExceptionSerializer.class)
12
-public class CustomOauthException extends OAuth2Exception
13
-{
14
-    private static final long serialVersionUID = 1L;
15
-
16
-    public CustomOauthException(String msg)
17
-    {
18
-        super(msg);
19
-    }
20
-}

+ 0 - 48
ruoyi-auth/src/main/java/com/ruoyi/auth/exception/CustomOauthExceptionSerializer.java

@@ -1,48 +0,0 @@
1
-package com.ruoyi.auth.exception;
2
-
3
-import java.io.IOException;
4
-import org.slf4j.Logger;
5
-import org.slf4j.LoggerFactory;
6
-import com.fasterxml.jackson.core.JsonGenerator;
7
-import com.fasterxml.jackson.databind.SerializerProvider;
8
-import com.fasterxml.jackson.databind.ser.std.StdSerializer;
9
-import com.ruoyi.common.core.constant.HttpStatus;
10
-import com.ruoyi.common.core.utils.StringUtils;
11
-import com.ruoyi.common.core.web.domain.AjaxResult;
12
-
13
-/**
14
- * 自定义异常返回
15
- *
16
- * @author ruoyi
17
- **/
18
-public class CustomOauthExceptionSerializer extends StdSerializer<CustomOauthException>
19
-{
20
-    private static final long serialVersionUID = 1L;
21
-
22
-    private static final Logger log = LoggerFactory.getLogger(CustomOauthExceptionSerializer.class);
23
-
24
-    public static final String BAD_CREDENTIALS = "Bad credentials";
25
-
26
-    public CustomOauthExceptionSerializer()
27
-    {
28
-        super(CustomOauthException.class);
29
-    }
30
-
31
-    @Override
32
-    public void serialize(CustomOauthException e, JsonGenerator jsonGenerator, SerializerProvider serializerProvider)
33
-            throws IOException
34
-    {
35
-        jsonGenerator.writeStartObject();
36
-        jsonGenerator.writeNumberField(AjaxResult.CODE_TAG, HttpStatus.ERROR);
37
-        if (StringUtils.equals(e.getMessage(), BAD_CREDENTIALS))
38
-        {
39
-            jsonGenerator.writeStringField(AjaxResult.MSG_TAG, "用户名或密码错误");
40
-        }
41
-        else
42
-        {
43
-            log.warn("oauth2 认证异常 {} ", e);
44
-            jsonGenerator.writeStringField(AjaxResult.MSG_TAG, e.getMessage());
45
-        }
46
-        jsonGenerator.writeEndObject();
47
-    }
48
-}

+ 0 - 20
ruoyi-auth/src/main/java/com/ruoyi/auth/exception/CustomWebResponseExceptionTranslator.java

@@ -1,20 +0,0 @@
1
-package com.ruoyi.auth.exception;
2
-
3
-import org.springframework.http.HttpStatus;
4
-import org.springframework.http.ResponseEntity;
5
-import org.springframework.security.oauth2.common.exceptions.OAuth2Exception;
6
-import org.springframework.security.oauth2.provider.error.WebResponseExceptionTranslator;
7
-
8
-/**
9
- * OAuth2 自定义异常处理
10
- * 
11
- * @author ruoyi
12
- */
13
-public class CustomWebResponseExceptionTranslator implements WebResponseExceptionTranslator<OAuth2Exception>
14
-{
15
-    @Override
16
-    public ResponseEntity<OAuth2Exception> translate(Exception e)
17
-    {
18
-        return ResponseEntity.status(HttpStatus.OK).body(new CustomOauthException(e.getMessage()));
19
-    }
20
-}

+ 69 - 0
ruoyi-auth/src/main/java/com/ruoyi/auth/form/LoginBody.java

@@ -0,0 +1,69 @@
1
+package com.ruoyi.auth.form;
2
+
3
+/**
4
+ * 用户登录对象
5
+ * 
6
+ * @author ruoyi
7
+ */
8
+public class LoginBody
9
+{
10
+    /**
11
+     * 用户名
12
+     */
13
+    private String username;
14
+
15
+    /**
16
+     * 用户密码
17
+     */
18
+    private String password;
19
+
20
+    /**
21
+     * 验证码
22
+     */
23
+    private String code;
24
+
25
+    /**
26
+     * 唯一标识
27
+     */
28
+    private String uuid = "";
29
+
30
+    public String getUsername()
31
+    {
32
+        return username;
33
+    }
34
+
35
+    public void setUsername(String username)
36
+    {
37
+        this.username = username;
38
+    }
39
+
40
+    public String getPassword()
41
+    {
42
+        return password;
43
+    }
44
+
45
+    public void setPassword(String password)
46
+    {
47
+        this.password = password;
48
+    }
49
+
50
+    public String getCode()
51
+    {
52
+        return code;
53
+    }
54
+
55
+    public void setCode(String code)
56
+    {
57
+        this.code = code;
58
+    }
59
+
60
+    public String getUuid()
61
+    {
62
+        return uuid;
63
+    }
64
+
65
+    public void setUuid(String uuid)
66
+    {
67
+        this.uuid = uuid;
68
+    }
69
+}

+ 0 - 39
ruoyi-auth/src/main/java/com/ruoyi/auth/handler/AuthenticationSuccessEventHandler.java

@@ -1,39 +0,0 @@
1
-package com.ruoyi.auth.handler;
2
-
3
-import org.springframework.beans.factory.annotation.Autowired;
4
-import org.springframework.context.ApplicationListener;
5
-import org.springframework.security.authentication.event.AuthenticationSuccessEvent;
6
-import org.springframework.security.core.Authentication;
7
-import org.springframework.stereotype.Component;
8
-import com.ruoyi.common.core.constant.Constants;
9
-import com.ruoyi.common.core.utils.StringUtils;
10
-import com.ruoyi.common.security.domain.LoginUser;
11
-import com.ruoyi.system.api.RemoteLogService;
12
-
13
-/**
14
- * 认证成功处理
15
- * 
16
- * @author ruoyi
17
- */
18
-@Component
19
-public class AuthenticationSuccessEventHandler implements ApplicationListener<AuthenticationSuccessEvent>
20
-{
21
-    @Autowired
22
-    private RemoteLogService remoteLogService;
23
-
24
-    @Override
25
-    public void onApplicationEvent(AuthenticationSuccessEvent event)
26
-    {
27
-        Authentication authentication = (Authentication) event.getSource();
28
-        if (StringUtils.isNotEmpty(authentication.getAuthorities())
29
-                && authentication.getPrincipal() instanceof LoginUser)
30
-        {
31
-            LoginUser user = (LoginUser) authentication.getPrincipal();
32
-
33
-            String username = user.getUsername();
34
-
35
-            // 记录用户登录日志
36
-            remoteLogService.saveLogininfor(username, Constants.LOGIN_SUCCESS, "登录成功");
37
-        }
38
-    }
39
-}

+ 89 - 0
ruoyi-auth/src/main/java/com/ruoyi/auth/service/SysLoginService.java

@@ -0,0 +1,89 @@
1
+package com.ruoyi.auth.service;
2
+
3
+import org.springframework.beans.factory.annotation.Autowired;
4
+import org.springframework.stereotype.Component;
5
+import com.ruoyi.common.core.constant.Constants;
6
+import com.ruoyi.common.core.constant.UserConstants;
7
+import com.ruoyi.common.core.domain.R;
8
+import com.ruoyi.common.core.enums.UserStatus;
9
+import com.ruoyi.common.core.exception.BaseException;
10
+import com.ruoyi.common.core.utils.StringUtils;
11
+import com.ruoyi.common.security.utils.SecurityUtils;
12
+import com.ruoyi.system.api.RemoteLogService;
13
+import com.ruoyi.system.api.RemoteUserService;
14
+import com.ruoyi.system.api.domain.SysUser;
15
+import com.ruoyi.system.api.model.LoginUser;
16
+
17
+/**
18
+ * 登录校验方法
19
+ * 
20
+ * @author ruoyi
21
+ */
22
+@Component
23
+public class SysLoginService
24
+{
25
+    @Autowired
26
+    private RemoteLogService remoteLogService;
27
+
28
+    @Autowired
29
+    private RemoteUserService remoteUserService;
30
+
31
+    /**
32
+     * 登录
33
+     */
34
+    public LoginUser login(String username, String password)
35
+    {
36
+        // 用户名或密码为空 错误
37
+        if (StringUtils.isAnyBlank(username, password))
38
+        {
39
+            remoteLogService.saveLogininfor(username, Constants.LOGIN_FAIL, "用户/密码必须填写");
40
+            throw new BaseException("用户/密码必须填写");
41
+        }
42
+        // 密码如果不在指定范围内 错误
43
+        if (password.length() < UserConstants.PASSWORD_MIN_LENGTH
44
+                || password.length() > UserConstants.PASSWORD_MAX_LENGTH)
45
+        {
46
+            remoteLogService.saveLogininfor(username, Constants.LOGIN_FAIL, "用户密码不在指定范围");
47
+            throw new BaseException("用户密码不在指定范围");
48
+        }
49
+        // 用户名不在指定范围内 错误
50
+        if (username.length() < UserConstants.USERNAME_MIN_LENGTH
51
+                || username.length() > UserConstants.USERNAME_MAX_LENGTH)
52
+        {
53
+            remoteLogService.saveLogininfor(username, Constants.LOGIN_FAIL, "用户名不在指定范围");
54
+            throw new BaseException("用户名不在指定范围");
55
+        }
56
+        // 查询用户信息
57
+        R<LoginUser> userResult = remoteUserService.getUserInfo(username);
58
+        if (StringUtils.isNull(userResult) || StringUtils.isNull(userResult.getData()))
59
+        {
60
+            remoteLogService.saveLogininfor(username, Constants.LOGIN_FAIL, "登录用户不存在");
61
+            throw new BaseException("登录用户:" + username + " 不存在");
62
+        }
63
+        LoginUser userInfo = userResult.getData();
64
+        SysUser user = userResult.getData().getSysUser();
65
+        if (UserStatus.DELETED.getCode().equals(user.getDelFlag()))
66
+        {
67
+            remoteLogService.saveLogininfor(username, Constants.LOGIN_FAIL, "对不起,您的账号已被删除");
68
+
69
+            throw new BaseException("对不起,您的账号:" + username + " 已被删除");
70
+        }
71
+        if (UserStatus.DISABLE.getCode().equals(user.getStatus()))
72
+        {
73
+            remoteLogService.saveLogininfor(username, Constants.LOGIN_FAIL, "用户已停用,请联系管理员");
74
+            throw new BaseException("对不起,您的账号:" + username + " 已停用");
75
+        }
76
+        if (!SecurityUtils.matchesPassword(password, user.getPassword()))
77
+        {
78
+            remoteLogService.saveLogininfor(username, Constants.LOGIN_FAIL, "用户密码错误");
79
+            throw new BaseException("用户不存在/密码错误");
80
+        }
81
+        remoteLogService.saveLogininfor(username, Constants.LOGIN_SUCCESS, "登录成功");
82
+        return userInfo;
83
+    }
84
+
85
+    public void logout(String loginName)
86
+    {
87
+        remoteLogService.saveLogininfor(loginName, Constants.LOGOUT, "退出成功");
88
+    }
89
+}

+ 19 - 4
ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/constant/CacheConstants.java

@@ -8,12 +8,27 @@ package com.ruoyi.common.core.constant;
8 8
 public class CacheConstants
9 9
 {
10 10
     /**
11
-     * oauth 缓存前缀
11
+     * 令牌自定义标识
12 12
      */
13
-    public static final String OAUTH_ACCESS = "oauth:access:";
13
+    public static final String HEADER = "Authorization";
14 14
 
15 15
     /**
16
-     * oauth 客户端信息
16
+     * 令牌前缀
17 17
      */
18
-    public static final String CLIENT_DETAILS_KEY = "oauth:client:details";
18
+    public static final String TOKEN_PREFIX = "Bearer ";
19
+
20
+    /**
21
+     * 权限缓存前缀
22
+     */
23
+    public final static String LOGIN_TOKEN_KEY = "login_tokens:";
24
+
25
+    /**
26
+     * 用户ID字段
27
+     */
28
+    public static final String DETAILS_USER_ID = "user_id";
29
+
30
+    /**
31
+     * 用户名字段
32
+     */
33
+    public static final String DETAILS_USERNAME = "username";
19 34
 }

+ 6 - 1
ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/constant/Constants.java

@@ -85,7 +85,12 @@ public class Constants
85 85
     /**
86 86
      * 验证码有效期(分钟)
87 87
      */
88
-    public static final Integer CAPTCHA_EXPIRATION = 2;
88
+    public static final long CAPTCHA_EXPIRATION = 2;
89
+
90
+    /**
91
+     * 令牌有效期(分钟)
92
+     */
93
+    public final static long TOKEN_EXPIRE = 30;
89 94
 
90 95
     /**
91 96
      * 参数管理 cache key

+ 0 - 56
ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/constant/SecurityConstants.java

@@ -1,56 +0,0 @@
1
-package com.ruoyi.common.core.constant;
2
-
3
-/**
4
- * 权限相关通用常量
5
- * 
6
- * @author ruoyi
7
- */
8
-public class SecurityConstants
9
-{
10
-    /**
11
-     * 令牌类型
12
-     */
13
-    public static final String BEARER_TOKEN_TYPE = "Bearer";
14
-
15
-    /**
16
-     * 授权token url
17
-     */
18
-    public static final String AUTH_TOKEN = "/oauth/token";
19
-
20
-    /**
21
-     * 注销token url
22
-     */
23
-    public static final String TOKEN_LOGOUT = "/token/logout";
24
-
25
-    /**
26
-     * 用户ID字段
27
-     */
28
-    public static final String DETAILS_USER_ID = "user_id";
29
-
30
-    /**
31
-     * 用户名字段
32
-     */
33
-    public static final String DETAILS_USERNAME = "username";
34
-
35
-    /**
36
-     * sys_oauth_client_details 表的字段,不包括client_id、client_secret
37
-     */
38
-    public static final String CLIENT_FIELDS = "client_id, client_secret, resource_ids, scope, "
39
-            + "authorized_grant_types, web_server_redirect_uri, authorities, access_token_validity, "
40
-            + "refresh_token_validity, additional_information, autoapprove";
41
-
42
-    /**
43
-     * JdbcClientDetailsService 查询语句
44
-     */
45
-    public static final String BASE_FIND_STATEMENT = "select " + CLIENT_FIELDS + " from sys_oauth_client_details";
46
-
47
-    /**
48
-     * 按条件client_id 查询
49
-     */
50
-    public static final String DEFAULT_SELECT_STATEMENT = BASE_FIND_STATEMENT + " where client_id = ?";
51
-
52
-    /**
53
-     * 默认的查询语句
54
-     */
55
-    public static final String DEFAULT_FIND_STATEMENT = BASE_FIND_STATEMENT + " order by client_id";
56
-}

+ 15 - 0
ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/constant/UserConstants.java

@@ -56,5 +56,20 @@ public class UserConstants
56 56
 
57 57
     /** 校验返回结果码 */
58 58
     public final static String UNIQUE = "0";
59
+
59 60
     public final static String NOT_UNIQUE = "1";
61
+
62
+    /**
63
+     * 用户名长度限制
64
+     */
65
+    public static final int USERNAME_MIN_LENGTH = 2;
66
+
67
+    public static final int USERNAME_MAX_LENGTH = 20;
68
+
69
+    /**
70
+     * 密码长度限制
71
+     */
72
+    public static final int PASSWORD_MIN_LENGTH = 5;
73
+
74
+    public static final int PASSWORD_MAX_LENGTH = 20;
60 75
 }

+ 15 - 0
ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/exception/PreAuthorizeException.java

@@ -0,0 +1,15 @@
1
+package com.ruoyi.common.core.exception;
2
+
3
+/**
4
+ * 权限异常
5
+ * 
6
+ * @author ruoyi
7
+ */
8
+public class PreAuthorizeException extends RuntimeException
9
+{
10
+    private static final long serialVersionUID = 1L;
11
+
12
+    public PreAuthorizeException()
13
+    {
14
+    }
15
+}

+ 4 - 4
ruoyi-common/ruoyi-common-datascope/src/main/java/com/ruoyi/common/datascope/aspect/DataScopeAspect.java

@@ -12,10 +12,10 @@ import org.springframework.stereotype.Component;
12 12
 import com.ruoyi.common.core.utils.StringUtils;
13 13
 import com.ruoyi.common.core.web.domain.BaseEntity;
14 14
 import com.ruoyi.common.datascope.annotation.DataScope;
15
-import com.ruoyi.common.datascope.service.AwaitUserService;
15
+import com.ruoyi.common.security.service.TokenService;
16 16
 import com.ruoyi.system.api.domain.SysRole;
17 17
 import com.ruoyi.system.api.domain.SysUser;
18
-import com.ruoyi.system.api.model.UserInfo;
18
+import com.ruoyi.system.api.model.LoginUser;
19 19
 
20 20
 /**
21 21
  * 数据过滤处理
@@ -57,7 +57,7 @@ public class DataScopeAspect
57 57
     public static final String DATA_SCOPE = "dataScope";
58 58
 
59 59
     @Autowired
60
-    private AwaitUserService awaitUserService;
60
+    private TokenService tokenService;
61 61
 
62 62
     // 配置织入点
63 63
     @Pointcut("@annotation(com.ruoyi.common.datascope.annotation.DataScope)")
@@ -80,7 +80,7 @@ public class DataScopeAspect
80 80
             return;
81 81
         }
82 82
         // 获取当前的用户
83
-        UserInfo loginUser = awaitUserService.info();
83
+        LoginUser loginUser = tokenService.getLoginUser();
84 84
         SysUser currentUser = loginUser.getSysUser();
85 85
         if (currentUser != null)
86 86
         {

+ 0 - 42
ruoyi-common/ruoyi-common-datascope/src/main/java/com/ruoyi/common/datascope/service/AwaitUserService.java

@@ -1,42 +0,0 @@
1
-package com.ruoyi.common.datascope.service;
2
-
3
-import org.slf4j.Logger;
4
-import org.slf4j.LoggerFactory;
5
-import org.springframework.beans.factory.annotation.Autowired;
6
-import org.springframework.stereotype.Service;
7
-import com.ruoyi.common.core.domain.R;
8
-import com.ruoyi.common.core.utils.StringUtils;
9
-import com.ruoyi.common.security.utils.SecurityUtils;
10
-import com.ruoyi.system.api.RemoteUserService;
11
-import com.ruoyi.system.api.model.UserInfo;
12
-
13
-/**
14
- * 同步调用用户服务
15
- * 
16
- * @author ruoyi
17
- */
18
-@Service
19
-public class AwaitUserService
20
-{
21
-    private static final Logger log = LoggerFactory.getLogger(AwaitUserService.class);
22
-
23
-    @Autowired
24
-    private RemoteUserService remoteUserService;
25
-
26
-    /**
27
-     * 查询当前用户信息
28
-     * 
29
-     * @return 用户基本信息
30
-     */
31
-    public UserInfo info()
32
-    {
33
-        String username = SecurityUtils.getUsername();
34
-        R<UserInfo> userResult = remoteUserService.getUserInfo(username);
35
-        if (StringUtils.isNull(userResult) || StringUtils.isNull(userResult.getData()))
36
-        {
37
-            log.info("数据权限范围查询用户:{} 不存在.", username);
38
-            return null;
39
-        }
40
-        return userResult.getData();
41
-    }
42
-}

+ 0 - 1
ruoyi-common/ruoyi-common-datascope/src/main/resources/META-INF/spring.factories

@@ -1,5 +1,4 @@
1 1
 org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
2
-  com.ruoyi.common.datascope.service.AwaitUserService,\
3 2
   com.ruoyi.common.datascope.aspect.DataScopeAspect
4 3
 
5 4
   

+ 5 - 14
ruoyi-common/ruoyi-common-log/src/main/java/com/ruoyi/common/log/aspect/LogAspect.java

@@ -1,7 +1,6 @@
1 1
 package com.ruoyi.common.log.aspect;
2 2
 
3 3
 import java.lang.reflect.Method;
4
-import java.util.Map;
5 4
 import javax.servlet.http.HttpServletRequest;
6 5
 import javax.servlet.http.HttpServletResponse;
7 6
 import org.aspectj.lang.JoinPoint;
@@ -17,16 +16,14 @@ import org.springframework.beans.factory.annotation.Autowired;
17 16
 import org.springframework.http.HttpMethod;
18 17
 import org.springframework.stereotype.Component;
19 18
 import org.springframework.web.multipart.MultipartFile;
20
-import org.springframework.web.servlet.HandlerMapping;
21 19
 import com.alibaba.fastjson.JSON;
20
+import com.ruoyi.common.core.constant.CacheConstants;
22 21
 import com.ruoyi.common.core.utils.ServletUtils;
23 22
 import com.ruoyi.common.core.utils.StringUtils;
24 23
 import com.ruoyi.common.core.utils.ip.IpUtils;
25 24
 import com.ruoyi.common.log.annotation.Log;
26 25
 import com.ruoyi.common.log.enums.BusinessStatus;
27 26
 import com.ruoyi.common.log.service.AsyncLogService;
28
-import com.ruoyi.common.security.domain.LoginUser;
29
-import com.ruoyi.common.security.utils.SecurityUtils;
30 27
 import com.ruoyi.system.api.domain.SysOperLog;
31 28
 
32 29
 /**
@@ -83,9 +80,6 @@ public class LogAspect
83 80
                 return;
84 81
             }
85 82
 
86
-            // 获取当前的用户
87
-            LoginUser loginUser = SecurityUtils.getLoginUser();
88
-
89 83
             // *========数据库日志=========*//
90 84
             SysOperLog operLog = new SysOperLog();
91 85
             operLog.setStatus(BusinessStatus.SUCCESS.ordinal());
@@ -96,9 +90,11 @@ public class LogAspect
96 90
             operLog.setJsonResult(JSON.toJSONString(jsonResult));
97 91
 
98 92
             operLog.setOperUrl(ServletUtils.getRequest().getRequestURI());
99
-            if (loginUser != null)
93
+            HttpServletRequest request = ServletUtils.getRequest();
94
+            String username = request.getHeader(CacheConstants.DETAILS_USERNAME);
95
+            if (StringUtils.isNotBlank(username))
100 96
             {
101
-                operLog.setOperName(loginUser.getUsername());
97
+                operLog.setOperName(username);
102 98
             }
103 99
 
104 100
             if (e != null)
@@ -163,11 +159,6 @@ public class LogAspect
163 159
             String params = argsArrayToString(joinPoint.getArgs());
164 160
             operLog.setOperParam(StringUtils.substring(params, 0, 2000));
165 161
         }
166
-        else
167
-        {
168
-            Map<?, ?> paramsMap = (Map<?, ?>) ServletUtils.getRequest().getAttribute(HandlerMapping.URI_TEMPLATE_VARIABLES_ATTRIBUTE);
169
-            operLog.setOperParam(StringUtils.substring(paramsMap.toString(), 0, 2000));
170
-        }
171 162
     }
172 163
 
173 164
     /**

+ 1 - 1
ruoyi-common/ruoyi-common-redis/src/main/java/com/ruoyi/common/redis/service/RedisService.java

@@ -42,7 +42,7 @@ public class RedisService
42 42
      * @param timeout 时间
43 43
      * @param timeUnit 时间颗粒度
44 44
      */
45
-    public <T> void setCacheObject(final String key, final T value, final Integer timeout, final TimeUnit timeUnit)
45
+    public <T> void setCacheObject(final String key, final T value, final Long timeout, final TimeUnit timeUnit)
46 46
     {
47 47
         redisTemplate.opsForValue().set(key, value, timeout, timeUnit);
48 48
     }

+ 5 - 5
ruoyi-common/ruoyi-common-security/pom.xml

@@ -16,16 +16,16 @@
16 16
 
17 17
     <dependencies>
18 18
     
19
-        <!-- Spring Security Oauth2 -->
19
+        <!-- RuoYi Api System -->
20 20
         <dependency>
21
-            <groupId>org.springframework.cloud</groupId>
22
-            <artifactId>spring-cloud-starter-oauth2</artifactId>
21
+            <groupId>com.ruoyi</groupId>
22
+            <artifactId>ruoyi-api-system</artifactId>
23 23
         </dependency>
24 24
         
25
-        <!-- RuoYi Api System -->
25
+        <!-- RuoYi Common Redis-->
26 26
         <dependency>
27 27
             <groupId>com.ruoyi</groupId>
28
-            <artifactId>ruoyi-api-system</artifactId>
28
+            <artifactId>ruoyi-common-redis</artifactId>
29 29
         </dependency>
30 30
         
31 31
     </dependencies>

+ 1 - 3
ruoyi-common/ruoyi-common-security/src/main/java/com/ruoyi/common/security/annotation/EnableCustomConfig.java

@@ -5,9 +5,7 @@ import org.mybatis.spring.annotation.MapperScan;
5 5
 import org.springframework.context.annotation.EnableAspectJAutoProxy;
6 6
 import org.springframework.context.annotation.Import;
7 7
 import org.springframework.scheduling.annotation.EnableAsync;
8
-import com.ruoyi.common.security.feign.OAuth2FeignConfig;
9 8
 import com.ruoyi.common.security.config.ApplicationConfig;
10
-import com.ruoyi.common.security.config.SecurityImportBeanDefinitionRegistrar;
11 9
 
12 10
 @Target(ElementType.TYPE)
13 11
 @Retention(RetentionPolicy.RUNTIME)
@@ -20,7 +18,7 @@ import com.ruoyi.common.security.config.SecurityImportBeanDefinitionRegistrar;
20 18
 // 开启线程异步执行
21 19
 @EnableAsync
22 20
 // 自动加载类
23
-@Import({ SecurityImportBeanDefinitionRegistrar.class, OAuth2FeignConfig.class, ApplicationConfig.class })
21
+@Import({ApplicationConfig.class})
24 22
 public @interface EnableCustomConfig
25 23
 {
26 24
 

+ 46 - 0
ruoyi-common/ruoyi-common-security/src/main/java/com/ruoyi/common/security/annotation/PreAuthorize.java

@@ -0,0 +1,46 @@
1
+package com.ruoyi.common.security.annotation;
2
+
3
+import java.lang.annotation.ElementType;
4
+import java.lang.annotation.Retention;
5
+import java.lang.annotation.RetentionPolicy;
6
+import java.lang.annotation.Target;
7
+
8
+/**
9
+ * 权限注解
10
+ * 
11
+ * @author ruoyi
12
+ */
13
+@Target({ ElementType.TYPE, ElementType.METHOD })
14
+@Retention(RetentionPolicy.RUNTIME)
15
+public @interface PreAuthorize
16
+{
17
+    /**
18
+     * 验证用户是否具备某权限
19
+     */
20
+    public String hasPermi() default "";
21
+
22
+    /**
23
+     * 验证用户是否不具备某权限,与 hasPermi逻辑相反
24
+     */
25
+    public String lacksPermi() default "";
26
+
27
+    /**
28
+     * 验证用户是否具有以下任意一个权限
29
+     */
30
+    public String[] hasAnyPermi() default {};
31
+
32
+    /**
33
+     * 判断用户是否拥有某个角色
34
+     */
35
+    public String hasRole() default "";
36
+
37
+    /**
38
+     * 验证用户是否不具备某角色,与 isRole逻辑相反
39
+     */
40
+    public String lacksRole() default "";
41
+
42
+    /**
43
+     * 验证用户是否具有以下任意一个角色
44
+     */
45
+    public String[] hasAnyRoles() default {};
46
+}

+ 195 - 0
ruoyi-common/ruoyi-common-security/src/main/java/com/ruoyi/common/security/aspect/PreAuthorizeAspect.java

@@ -0,0 +1,195 @@
1
+package com.ruoyi.common.security.aspect;
2
+
3
+import java.lang.reflect.Method;
4
+import java.util.Collection;
5
+import org.aspectj.lang.ProceedingJoinPoint;
6
+import org.aspectj.lang.Signature;
7
+import org.aspectj.lang.annotation.Around;
8
+import org.aspectj.lang.annotation.Aspect;
9
+import org.aspectj.lang.reflect.MethodSignature;
10
+import org.springframework.beans.factory.annotation.Autowired;
11
+import org.springframework.stereotype.Component;
12
+import org.springframework.util.CollectionUtils;
13
+import org.springframework.util.PatternMatchUtils;
14
+import org.springframework.util.StringUtils;
15
+import com.ruoyi.common.core.exception.PreAuthorizeException;
16
+import com.ruoyi.common.security.annotation.PreAuthorize;
17
+import com.ruoyi.common.security.service.TokenService;
18
+import com.ruoyi.system.api.model.LoginUser;
19
+
20
+@Aspect
21
+@Component
22
+public class PreAuthorizeAspect
23
+{
24
+    @Autowired
25
+    private TokenService tokenService;
26
+
27
+    /** 所有权限标识 */
28
+    private static final String ALL_PERMISSION = "*:*:*";
29
+
30
+    /** 管理员角色权限标识 */
31
+    private static final String SUPER_ADMIN = "admin";
32
+
33
+    @Around("@annotation(com.ruoyi.common.security.annotation.PreAuthorize)")
34
+    public Object around(ProceedingJoinPoint point) throws Throwable
35
+    {
36
+        Signature signature = point.getSignature();
37
+        MethodSignature methodSignature = (MethodSignature) signature;
38
+        Method method = methodSignature.getMethod();
39
+        PreAuthorize annotation = method.getAnnotation(PreAuthorize.class);
40
+        if (annotation == null)
41
+        {
42
+            return point.proceed();
43
+        }
44
+
45
+        if (StringUtils.isEmpty(annotation.hasPermi()) && hasPermi(annotation.hasPermi()))
46
+        {
47
+            return point.proceed();
48
+        }
49
+        else if (StringUtils.isEmpty(annotation.lacksPermi()) && hasPermi(annotation.lacksPermi()))
50
+        {
51
+            return point.proceed();
52
+        }
53
+        else if (StringUtils.isEmpty(annotation.hasAnyPermi()) && hasAnyPermi(annotation.hasAnyPermi()))
54
+        {
55
+            return point.proceed();
56
+        }
57
+        else if (StringUtils.isEmpty(annotation.hasRole()) && hasRole(annotation.hasRole()))
58
+        {
59
+            return point.proceed();
60
+        }
61
+        else if (StringUtils.isEmpty(annotation.lacksRole()) && lacksRole(annotation.lacksRole()))
62
+        {
63
+            return point.proceed();
64
+        }
65
+        else if (StringUtils.isEmpty(annotation.hasAnyRoles()) && hasAnyRoles(annotation.hasAnyRoles()))
66
+        {
67
+            return point.proceed();
68
+        }
69
+        else
70
+        {
71
+            throw new PreAuthorizeException();
72
+        }
73
+    }
74
+
75
+    /**
76
+     * 验证用户是否具备某权限
77
+     * 
78
+     * @param permission 权限字符串
79
+     * @return 用户是否具备某权限
80
+     */
81
+    public boolean hasPermi(String permission)
82
+    {
83
+        LoginUser userInfo = tokenService.getLoginUser();
84
+        if (StringUtils.isEmpty(userInfo) || CollectionUtils.isEmpty(userInfo.getPermissions()))
85
+        {
86
+            return false;
87
+        }
88
+        return hasPermissions(userInfo.getPermissions(), permission);
89
+    }
90
+
91
+    /**
92
+     * 验证用户是否不具备某权限,与 hasPermi逻辑相反
93
+     *
94
+     * @param permission 权限字符串
95
+     * @return 用户是否不具备某权限
96
+     */
97
+    public boolean lacksPermi(String permission)
98
+    {
99
+        return hasPermi(permission) != true;
100
+    }
101
+
102
+    /**
103
+     * 验证用户是否具有以下任意一个权限
104
+     *
105
+     * @param permissions 权限列表
106
+     * @return 用户是否具有以下任意一个权限
107
+     */
108
+    public boolean hasAnyPermi(String[] permissions)
109
+    {
110
+        LoginUser userInfo = tokenService.getLoginUser();
111
+        if (StringUtils.isEmpty(userInfo) || CollectionUtils.isEmpty(userInfo.getPermissions()))
112
+        {
113
+            return false;
114
+        }
115
+        Collection<String> authorities = userInfo.getPermissions();
116
+        for (String permission : permissions)
117
+        {
118
+            if (permission != null && hasPermissions(authorities, permission))
119
+            {
120
+                return true;
121
+            }
122
+        }
123
+        return false;
124
+    }
125
+
126
+    /**
127
+     * 判断用户是否拥有某个角色
128
+     * 
129
+     * @param role 角色字符串
130
+     * @return 用户是否具备某角色
131
+     */
132
+    public boolean hasRole(String role)
133
+    {
134
+        LoginUser userInfo = tokenService.getLoginUser();
135
+        if (StringUtils.isEmpty(userInfo) || CollectionUtils.isEmpty(userInfo.getRoles()))
136
+        {
137
+            return false;
138
+        }
139
+        for (String roleKey : userInfo.getRoles())
140
+        {
141
+            if (SUPER_ADMIN.contains(roleKey) || roleKey.contains(role))
142
+            {
143
+                return true;
144
+            }
145
+        }
146
+        return false;
147
+    }
148
+
149
+    /**
150
+     * 验证用户是否不具备某角色,与 isRole逻辑相反。
151
+     *
152
+     * @param role 角色名称
153
+     * @return 用户是否不具备某角色
154
+     */
155
+    public boolean lacksRole(String role)
156
+    {
157
+        return hasRole(role) != true;
158
+    }
159
+
160
+    /**
161
+     * 验证用户是否具有以下任意一个角色
162
+     *
163
+     * @param roles 角色列表
164
+     * @return 用户是否具有以下任意一个角色
165
+     */
166
+    public boolean hasAnyRoles(String[] roles)
167
+    {
168
+        LoginUser userInfo = tokenService.getLoginUser();
169
+        if (StringUtils.isEmpty(userInfo) || CollectionUtils.isEmpty(userInfo.getRoles()))
170
+        {
171
+            return false;
172
+        }
173
+        for (String role : roles)
174
+        {
175
+            if (hasRole(role))
176
+            {
177
+                return true;
178
+            }
179
+        }
180
+        return false;
181
+    }
182
+
183
+    /**
184
+     * 判断是否包含权限
185
+     * 
186
+     * @param authorities 权限列表
187
+     * @param permission 权限字符串
188
+     * @return 用户是否具备某权限
189
+     */
190
+    private boolean hasPermissions(Collection<String> authorities, String permission)
191
+    {
192
+        return authorities.stream().filter(StringUtils::hasText)
193
+                .anyMatch(x -> ALL_PERMISSION.contains(x) || PatternMatchUtils.simpleMatch(permission, x));
194
+    }
195
+}

+ 0 - 30
ruoyi-common/ruoyi-common-security/src/main/java/com/ruoyi/common/security/config/AuthIgnoreConfig.java

@@ -1,30 +0,0 @@
1
-package com.ruoyi.common.security.config;
2
-
3
-import java.util.ArrayList;
4
-import java.util.List;
5
-import org.springframework.beans.factory.annotation.Configurable;
6
-import org.springframework.boot.context.properties.ConfigurationProperties;
7
-import org.springframework.stereotype.Component;
8
-
9
-/**
10
- * 忽略服务间的认证
11
- * 
12
- * @author ruoyi
13
- **/
14
-@Component
15
-@Configurable
16
-@ConfigurationProperties(prefix = "security.oauth2.ignore")
17
-public class AuthIgnoreConfig
18
-{
19
-    private List<String> urls = new ArrayList<>();
20
-
21
-    public List<String> getUrls()
22
-    {
23
-        return urls;
24
-    }
25
-
26
-    public void setUrls(List<String> urls)
27
-    {
28
-        this.urls = urls;
29
-    }
30
-}

+ 0 - 75
ruoyi-common/ruoyi-common-security/src/main/java/com/ruoyi/common/security/config/CommonUserConverter.java

@@ -1,75 +0,0 @@
1
-package com.ruoyi.common.security.config;
2
-
3
-import java.util.Collection;
4
-import java.util.LinkedHashMap;
5
-import java.util.Map;
6
-import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
7
-import org.springframework.security.core.Authentication;
8
-import org.springframework.security.core.GrantedAuthority;
9
-import org.springframework.security.core.authority.AuthorityUtils;
10
-import org.springframework.security.oauth2.provider.token.UserAuthenticationConverter;
11
-import org.springframework.util.StringUtils;
12
-import com.ruoyi.common.core.constant.SecurityConstants;
13
-import com.ruoyi.common.core.text.Convert;
14
-import com.ruoyi.common.security.domain.LoginUser;
15
-
16
-/**
17
- * https://my.oschina.net/giegie/blog/3023768 根据checktoken 的结果转化用户信息
18
- * 
19
- * @author lengleng
20
- */
21
-public class CommonUserConverter implements UserAuthenticationConverter
22
-{
23
-    private static final String N_A = "N/A";
24
-
25
-    /**
26
-     * 将授权信息返回到资源服务
27
-     */
28
-    @Override
29
-    public Map<String, ?> convertUserAuthentication(Authentication userAuthentication)
30
-    {
31
-        Map<String, Object> authMap = new LinkedHashMap<>();
32
-        authMap.put(USERNAME, userAuthentication.getName());
33
-        if (userAuthentication.getAuthorities() != null && !userAuthentication.getAuthorities().isEmpty())
34
-        {
35
-            authMap.put(AUTHORITIES, AuthorityUtils.authorityListToSet(userAuthentication.getAuthorities()));
36
-        }
37
-        return authMap;
38
-    }
39
-
40
-    /**
41
-     * 获取用户认证信息
42
-     */
43
-    @Override
44
-    public Authentication extractAuthentication(Map<String, ?> map)
45
-    {
46
-        if (map.containsKey(USERNAME))
47
-        {
48
-            Collection<? extends GrantedAuthority> authorities = getAuthorities(map);
49
-
50
-            Long userId = Convert.toLong(map.get(SecurityConstants.DETAILS_USER_ID));
51
-            String username = (String) map.get(SecurityConstants.DETAILS_USERNAME);
52
-            LoginUser user = new LoginUser(userId, username, N_A, true, true, true, true, authorities);
53
-            return new UsernamePasswordAuthenticationToken(user, N_A, authorities);
54
-        }
55
-        return null;
56
-    }
57
-
58
-    /**
59
-     * 获取权限资源信息
60
-     */
61
-    private Collection<? extends GrantedAuthority> getAuthorities(Map<String, ?> map)
62
-    {
63
-        Object authorities = map.get(AUTHORITIES);
64
-        if (authorities instanceof String)
65
-        {
66
-            return AuthorityUtils.commaSeparatedStringToAuthorityList((String) authorities);
67
-        }
68
-        if (authorities instanceof Collection)
69
-        {
70
-            return AuthorityUtils.commaSeparatedStringToAuthorityList(
71
-                    StringUtils.collectionToCommaDelimitedString((Collection<?>) authorities));
72
-        }
73
-        throw new IllegalArgumentException("Authorities must be either a String or a Collection");
74
-    }
75
-}

+ 0 - 27
ruoyi-common/ruoyi-common-security/src/main/java/com/ruoyi/common/security/config/MethodSecurityConfig.java

@@ -1,27 +0,0 @@
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
-}

+ 0 - 82
ruoyi-common/ruoyi-common-security/src/main/java/com/ruoyi/common/security/config/ResourceServerConfig.java

@@ -1,82 +0,0 @@
1
-package com.ruoyi.common.security.config;
2
-
3
-import org.springframework.beans.factory.annotation.Autowired;
4
-import org.springframework.boot.autoconfigure.security.oauth2.OAuth2ClientProperties;
5
-import org.springframework.boot.autoconfigure.security.oauth2.resource.ResourceServerProperties;
6
-import org.springframework.cloud.client.loadbalancer.LoadBalanced;
7
-import org.springframework.context.annotation.Bean;
8
-import org.springframework.context.annotation.Configuration;
9
-import org.springframework.security.config.annotation.web.builders.HttpSecurity;
10
-import org.springframework.security.config.annotation.web.configurers.ExpressionUrlAuthorizationConfigurer;
11
-import org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer;
12
-import org.springframework.security.oauth2.config.annotation.web.configuration.ResourceServerConfigurerAdapter;
13
-import org.springframework.security.oauth2.config.annotation.web.configurers.ResourceServerSecurityConfigurer;
14
-import org.springframework.security.oauth2.provider.token.DefaultAccessTokenConverter;
15
-import org.springframework.security.oauth2.provider.token.RemoteTokenServices;
16
-import org.springframework.security.oauth2.provider.token.ResourceServerTokenServices;
17
-import org.springframework.security.oauth2.provider.token.UserAuthenticationConverter;
18
-import org.springframework.web.client.DefaultResponseErrorHandler;
19
-import org.springframework.web.client.RestTemplate;
20
-
21
-/**
22
- * oauth2 服务配置
23
- * 
24
- * @author ruoyi
25
- */
26
-@Configuration
27
-@EnableResourceServer
28
-public class ResourceServerConfig extends ResourceServerConfigurerAdapter
29
-{
30
-    @Autowired
31
-    private ResourceServerProperties resourceServerProperties;
32
-
33
-    @Autowired
34
-    private OAuth2ClientProperties oAuth2ClientProperties;
35
-
36
-    @Bean
37
-    public AuthIgnoreConfig authIgnoreConfig()
38
-    {
39
-        return new AuthIgnoreConfig();
40
-    }
41
-
42
-    @Bean
43
-    @LoadBalanced
44
-    public RestTemplate restTemplate()
45
-    {
46
-        RestTemplate restTemplate = new RestTemplate();
47
-        restTemplate.setErrorHandler(new DefaultResponseErrorHandler());
48
-        return restTemplate;
49
-    }
50
-
51
-    @Bean
52
-    public ResourceServerTokenServices tokenServices()
53
-    {
54
-        RemoteTokenServices remoteTokenServices = new RemoteTokenServices();
55
-        DefaultAccessTokenConverter accessTokenConverter = new DefaultAccessTokenConverter();
56
-        UserAuthenticationConverter userTokenConverter = new CommonUserConverter();
57
-        accessTokenConverter.setUserTokenConverter(userTokenConverter);
58
-        remoteTokenServices.setCheckTokenEndpointUrl(resourceServerProperties.getTokenInfoUri());
59
-        remoteTokenServices.setClientId(oAuth2ClientProperties.getClientId());
60
-        remoteTokenServices.setClientSecret(oAuth2ClientProperties.getClientSecret());
61
-        remoteTokenServices.setRestTemplate(restTemplate());
62
-        remoteTokenServices.setAccessTokenConverter(accessTokenConverter);
63
-        return remoteTokenServices;
64
-    }
65
-
66
-    @Override
67
-    public void configure(HttpSecurity http) throws Exception
68
-    {
69
-        http.csrf().disable();
70
-        ExpressionUrlAuthorizationConfigurer<HttpSecurity>.ExpressionInterceptUrlRegistry registry = http
71
-                .authorizeRequests();
72
-        // 不登录可以访问
73
-        authIgnoreConfig().getUrls().forEach(url -> registry.antMatchers(url).permitAll());
74
-        registry.anyRequest().authenticated();
75
-    }
76
-
77
-    @Override
78
-    public void configure(ResourceServerSecurityConfigurer resources)
79
-    {
80
-        resources.tokenServices(tokenServices());
81
-    }
82
-}

+ 0 - 24
ruoyi-common/ruoyi-common-security/src/main/java/com/ruoyi/common/security/config/SecurityImportBeanDefinitionRegistrar.java

@@ -1,24 +0,0 @@
1
-package com.ruoyi.common.security.config;
2
-
3
-import org.springframework.beans.factory.support.BeanDefinitionBuilder;
4
-import org.springframework.beans.factory.support.BeanDefinitionRegistry;
5
-import org.springframework.context.annotation.ImportBeanDefinitionRegistrar;
6
-import org.springframework.core.type.AnnotationMetadata;
7
-import com.ruoyi.common.core.utils.StringUtils;
8
-
9
-/**
10
- * 导入 SecurityImportBeanDefinitionRegistrar 自动加载类
11
- * 
12
- * @author ruoyi
13
- */
14
-public class SecurityImportBeanDefinitionRegistrar implements ImportBeanDefinitionRegistrar
15
-{
16
-    @Override
17
-    public void registerBeanDefinitions(AnnotationMetadata metadata, BeanDefinitionRegistry registry)
18
-    {
19
-        Class<ResourceServerConfig> aClass = ResourceServerConfig.class;
20
-        String beanName = StringUtils.uncapitalize(aClass.getSimpleName());
21
-        BeanDefinitionBuilder beanDefinitionBuilder = BeanDefinitionBuilder.genericBeanDefinition(ResourceServerConfig.class);
22
-        registry.registerBeanDefinition(beanName, beanDefinitionBuilder.getBeanDefinition());
23
-    }
24
-}

+ 0 - 37
ruoyi-common/ruoyi-common-security/src/main/java/com/ruoyi/common/security/domain/LoginUser.java

@@ -1,37 +0,0 @@
1
-package com.ruoyi.common.security.domain;
2
-
3
-import java.util.Collection;
4
-import org.springframework.security.core.GrantedAuthority;
5
-import org.springframework.security.core.userdetails.User;
6
-
7
-/**
8
- * 登录用户身份权限
9
- * 
10
- * @author ruoyi
11
- */
12
-public class LoginUser extends User
13
-{
14
-    private static final long serialVersionUID = 1L;
15
-
16
-    /**
17
-     * 用户ID
18
-     */
19
-    private Long userId;
20
-
21
-    public LoginUser(Long userId, String username, String password, boolean enabled, boolean accountNonExpired,
22
-            boolean credentialsNonExpired, boolean accountNonLocked, Collection<? extends GrantedAuthority> authorities)
23
-    {
24
-        super(username, password, enabled, accountNonExpired, credentialsNonExpired, accountNonLocked, authorities);
25
-        this.userId = userId;
26
-    }
27
-
28
-    public Long getUserId()
29
-    {
30
-        return userId;
31
-    }
32
-
33
-    public void setUserId(Long userId)
34
-    {
35
-        this.userId = userId;
36
-    }
37
-}

+ 0 - 20
ruoyi-common/ruoyi-common-security/src/main/java/com/ruoyi/common/security/feign/OAuth2FeignConfig.java

@@ -1,20 +0,0 @@
1
-package com.ruoyi.common.security.feign;
2
-
3
-import org.springframework.context.annotation.Bean;
4
-import org.springframework.context.annotation.Configuration;
5
-import feign.RequestInterceptor;
6
-
7
-/**
8
- * Feign配置注册
9
- *
10
- * @author ruoyi
11
- **/
12
-@Configuration
13
-public class OAuth2FeignConfig
14
-{
15
-    @Bean
16
-    public RequestInterceptor requestInterceptor()
17
-    {
18
-        return new OAuth2FeignRequestInterceptor();
19
-    }
20
-}

+ 0 - 33
ruoyi-common/ruoyi-common-security/src/main/java/com/ruoyi/common/security/feign/OAuth2FeignRequestInterceptor.java

@@ -1,33 +0,0 @@
1
-package com.ruoyi.common.security.feign;
2
-
3
-import org.springframework.http.HttpHeaders;
4
-import org.springframework.security.core.Authentication;
5
-import org.springframework.security.core.context.SecurityContext;
6
-import org.springframework.security.core.context.SecurityContextHolder;
7
-import org.springframework.security.oauth2.provider.authentication.OAuth2AuthenticationDetails;
8
-import org.springframework.stereotype.Component;
9
-import com.ruoyi.common.core.constant.SecurityConstants;
10
-import feign.RequestInterceptor;
11
-import feign.RequestTemplate;
12
-
13
-/**
14
- * feign 请求拦截器
15
- * 
16
- * @author ruoyi
17
- */
18
-@Component
19
-public class OAuth2FeignRequestInterceptor implements RequestInterceptor
20
-{
21
-    @Override
22
-    public void apply(RequestTemplate requestTemplate)
23
-    {
24
-        SecurityContext securityContext = SecurityContextHolder.getContext();
25
-        Authentication authentication = securityContext.getAuthentication();
26
-        if (authentication != null && authentication.getDetails() instanceof OAuth2AuthenticationDetails)
27
-        {
28
-            OAuth2AuthenticationDetails dateils = (OAuth2AuthenticationDetails) authentication.getDetails();
29
-            requestTemplate.header(HttpHeaders.AUTHORIZATION,
30
-                    String.format("%s %s", SecurityConstants.BEARER_TOKEN_TYPE, dateils.getTokenValue()));
31
-        }
32
-    }
33
-}

+ 0 - 33
ruoyi-common/ruoyi-common-security/src/main/java/com/ruoyi/common/security/handler/CustomAccessDeniedHandler.java

@@ -1,33 +0,0 @@
1
-package com.ruoyi.common.security.handler;
2
-
3
-import javax.servlet.http.HttpServletRequest;
4
-import javax.servlet.http.HttpServletResponse;
5
-import org.slf4j.Logger;
6
-import org.slf4j.LoggerFactory;
7
-import org.springframework.security.access.AccessDeniedException;
8
-import org.springframework.security.oauth2.provider.error.OAuth2AccessDeniedHandler;
9
-import org.springframework.stereotype.Component;
10
-import com.alibaba.fastjson.JSON;
11
-import com.ruoyi.common.core.constant.HttpStatus;
12
-import com.ruoyi.common.core.domain.R;
13
-import com.ruoyi.common.core.utils.ServletUtils;
14
-
15
-/**
16
- * 自定义访问无权限资源时的异常
17
- * 
18
- * @author ruoyi
19
- */
20
-@Component
21
-public class CustomAccessDeniedHandler extends OAuth2AccessDeniedHandler
22
-{
23
-    private final Logger logger = LoggerFactory.getLogger(CustomAccessDeniedHandler.class);
24
-
25
-    @Override
26
-    public void handle(HttpServletRequest request, HttpServletResponse response, AccessDeniedException authException)
27
-    {
28
-        logger.info("权限不足,请联系管理员 {}", request.getRequestURI());
29
-
30
-        String msg = authException.getMessage();
31
-        ServletUtils.renderString(response, JSON.toJSONString(R.fail(HttpStatus.FORBIDDEN, msg)));
32
-    }
33
-}

+ 11 - 34
ruoyi-common/ruoyi-common-security/src/main/java/com/ruoyi/common/security/handler/GlobalExceptionHandler.java

@@ -2,18 +2,14 @@ package com.ruoyi.common.security.handler;
2 2
 
3 3
 import org.slf4j.Logger;
4 4
 import org.slf4j.LoggerFactory;
5
-import org.springframework.security.access.AccessDeniedException;
6
-import org.springframework.security.authentication.AccountExpiredException;
7
-import org.springframework.security.core.userdetails.UsernameNotFoundException;
8 5
 import org.springframework.validation.BindException;
9 6
 import org.springframework.web.bind.MethodArgumentNotValidException;
10 7
 import org.springframework.web.bind.annotation.ExceptionHandler;
11 8
 import org.springframework.web.bind.annotation.RestControllerAdvice;
12
-import org.springframework.web.servlet.NoHandlerFoundException;
13
-import com.ruoyi.common.core.constant.HttpStatus;
14 9
 import com.ruoyi.common.core.exception.BaseException;
15 10
 import com.ruoyi.common.core.exception.CustomException;
16 11
 import com.ruoyi.common.core.exception.DemoModeException;
12
+import com.ruoyi.common.core.exception.PreAuthorizeException;
17 13
 import com.ruoyi.common.core.utils.StringUtils;
18 14
 import com.ruoyi.common.core.web.domain.AjaxResult;
19 15
 
@@ -49,34 +45,6 @@ public class GlobalExceptionHandler
49 45
         return AjaxResult.error(e.getCode(), e.getMessage());
50 46
     }
51 47
 
52
-    @ExceptionHandler(NoHandlerFoundException.class)
53
-    public AjaxResult handlerNoFoundException(Exception e)
54
-    {
55
-        log.error(e.getMessage(), e);
56
-        return AjaxResult.error(HttpStatus.NOT_FOUND, "路径不存在,请检查路径是否正确");
57
-    }
58
-
59
-    @ExceptionHandler(AccessDeniedException.class)
60
-    public AjaxResult handleAuthorizationException(AccessDeniedException e)
61
-    {
62
-        log.error(e.getMessage());
63
-        return AjaxResult.error(HttpStatus.FORBIDDEN, "没有权限,请联系管理员授权");
64
-    }
65
-
66
-    @ExceptionHandler(AccountExpiredException.class)
67
-    public AjaxResult handleAccountExpiredException(AccountExpiredException e)
68
-    {
69
-        log.error(e.getMessage(), e);
70
-        return AjaxResult.error(e.getMessage());
71
-    }
72
-
73
-    @ExceptionHandler(UsernameNotFoundException.class)
74
-    public AjaxResult handleUsernameNotFoundException(UsernameNotFoundException e)
75
-    {
76
-        log.error(e.getMessage(), e);
77
-        return AjaxResult.error(e.getMessage());
78
-    }
79
-
80 48
     @ExceptionHandler(Exception.class)
81 49
     public AjaxResult handleException(Exception e)
82 50
     {
@@ -105,7 +73,16 @@ public class GlobalExceptionHandler
105 73
         String message = e.getBindingResult().getFieldError().getDefaultMessage();
106 74
         return AjaxResult.error(message);
107 75
     }
108
-
76
+    
77
+    /**
78
+     * 权限异常
79
+     */
80
+    @ExceptionHandler(PreAuthorizeException.class)
81
+    public AjaxResult preAuthorizeException(PreAuthorizeException e)
82
+    {
83
+        return AjaxResult.error("没有权限,请联系管理员授权");
84
+    }
85
+    
109 86
     /**
110 87
      * 演示模式异常
111 88
      */

+ 0 - 167
ruoyi-common/ruoyi-common-security/src/main/java/com/ruoyi/common/security/service/PermissionService.java

@@ -1,167 +0,0 @@
1
-package com.ruoyi.common.security.service;
2
-
3
-import java.util.Collection;
4
-import org.springframework.security.core.GrantedAuthority;
5
-import org.springframework.stereotype.Service;
6
-import org.springframework.util.CollectionUtils;
7
-import org.springframework.util.PatternMatchUtils;
8
-import org.springframework.util.StringUtils;
9
-import com.ruoyi.common.security.domain.LoginUser;
10
-import com.ruoyi.common.security.utils.SecurityUtils;
11
-
12
-/**
13
- * 自定义权限实现
14
- * 
15
- * @author ruoyi
16
- */
17
-@Service("ss")
18
-public class PermissionService
19
-{
20
-    /** 所有权限标识 */
21
-    private static final String ALL_PERMISSION = "*:*:*";
22
-
23
-    /** 管理员角色权限标识 */
24
-    private static final String SUPER_ADMIN = "admin";
25
-
26
-    private static final String ROLE_DELIMETER = ",";
27
-
28
-    private static final String PERMISSION_DELIMETER = ",";
29
-
30
-    /**
31
-     * 验证用户是否具备某权限
32
-     * 
33
-     * @param permission 权限字符串
34
-     * @return 用户是否具备某权限
35
-     */
36
-    public boolean hasPermi(String permission)
37
-    {
38
-        if (StringUtils.isEmpty(permission))
39
-        {
40
-            return false;
41
-        }
42
-        LoginUser loginUser = SecurityUtils.getLoginUser();
43
-        if (StringUtils.isEmpty(loginUser) || CollectionUtils.isEmpty(loginUser.getAuthorities()))
44
-        {
45
-            return false;
46
-        }
47
-        return hasPermissions(loginUser.getAuthorities(), permission);
48
-    }
49
-
50
-    /**
51
-     * 验证用户是否不具备某权限,与 hasPermi逻辑相反
52
-     *
53
-     * @param permission 权限字符串
54
-     * @return 用户是否不具备某权限
55
-     */
56
-    public boolean lacksPermi(String permission)
57
-    {
58
-        return hasPermi(permission) != true;
59
-    }
60
-
61
-    /**
62
-     * 验证用户是否具有以下任意一个权限
63
-     *
64
-     * @param permissions 以 PERMISSION_NAMES_DELIMETER 为分隔符的权限列表
65
-     * @return 用户是否具有以下任意一个权限
66
-     */
67
-    public boolean hasAnyPermi(String permissions)
68
-    {
69
-        if (StringUtils.isEmpty(permissions))
70
-        {
71
-            return false;
72
-        }
73
-        LoginUser loginUser = SecurityUtils.getLoginUser();
74
-        if (StringUtils.isEmpty(loginUser) || CollectionUtils.isEmpty(loginUser.getAuthorities()))
75
-        {
76
-            return false;
77
-        }
78
-        Collection<? extends GrantedAuthority> authorities = loginUser.getAuthorities();
79
-        for (String permission : permissions.split(PERMISSION_DELIMETER))
80
-        {
81
-            if (permission != null && hasPermissions(authorities, permission))
82
-            {
83
-                return true;
84
-            }
85
-        }
86
-        return false;
87
-    }
88
-
89
-    /**
90
-     * 判断用户是否拥有某个角色
91
-     * 
92
-     * @param role 角色字符串
93
-     * @return 用户是否具备某角色
94
-     */
95
-    public boolean hasRole(String role)
96
-    {
97
-        if (StringUtils.isEmpty(role))
98
-        {
99
-            return false;
100
-        }
101
-        LoginUser loginUser = SecurityUtils.getLoginUser();
102
-        if (StringUtils.isEmpty(loginUser) || CollectionUtils.isEmpty(loginUser.getAuthorities()))
103
-        {
104
-            return false;
105
-        }
106
-        for (GrantedAuthority authorities : loginUser.getAuthorities())
107
-        {
108
-            String roleKey = authorities.getAuthority();
109
-            if (SUPER_ADMIN.contains(roleKey) || roleKey.contains(role))
110
-            {
111
-                return true;
112
-            }
113
-        }
114
-        return false;
115
-    }
116
-
117
-    /**
118
-     * 验证用户是否不具备某角色,与 isRole逻辑相反。
119
-     *
120
-     * @param role 角色名称
121
-     * @return 用户是否不具备某角色
122
-     */
123
-    public boolean lacksRole(String role)
124
-    {
125
-        return hasRole(role) != true;
126
-    }
127
-
128
-    /**
129
-     * 验证用户是否具有以下任意一个角色
130
-     *
131
-     * @param roles 以 ROLE_NAMES_DELIMETER 为分隔符的角色列表
132
-     * @return 用户是否具有以下任意一个角色
133
-     */
134
-    public boolean hasAnyRoles(String roles)
135
-    {
136
-        if (StringUtils.isEmpty(roles))
137
-        {
138
-            return false;
139
-        }
140
-        LoginUser loginUser = SecurityUtils.getLoginUser();
141
-        if (StringUtils.isEmpty(loginUser) || CollectionUtils.isEmpty(loginUser.getAuthorities()))
142
-        {
143
-            return false;
144
-        }
145
-        for (String role : roles.split(ROLE_DELIMETER))
146
-        {
147
-            if (hasRole(role))
148
-            {
149
-                return true;
150
-            }
151
-        }
152
-        return false;
153
-    }
154
-
155
-    /**
156
-     * 判断是否包含权限
157
-     * 
158
-     * @param authorities 权限列表
159
-     * @param permission 权限字符串
160
-     * @return 用户是否具备某权限
161
-     */
162
-    private boolean hasPermissions(Collection<? extends GrantedAuthority> authorities, String permission)
163
-    {
164
-        return authorities.stream().map(GrantedAuthority::getAuthority).filter(StringUtils::hasText)
165
-                .anyMatch(x -> ALL_PERMISSION.contains(x) || PatternMatchUtils.simpleMatch(permission, x));
166
-    }
167
-}

+ 0 - 30
ruoyi-common/ruoyi-common-security/src/main/java/com/ruoyi/common/security/service/RedisClientDetailsService.java

@@ -1,30 +0,0 @@
1
-package com.ruoyi.common.security.service;
2
-
3
-import javax.sql.DataSource;
4
-import org.springframework.cache.annotation.Cacheable;
5
-import org.springframework.security.oauth2.provider.ClientDetails;
6
-import org.springframework.security.oauth2.provider.client.JdbcClientDetailsService;
7
-import com.ruoyi.common.core.constant.CacheConstants;
8
-import com.ruoyi.common.core.constant.SecurityConstants;
9
-
10
-/**
11
- * 重写原生方法支持redis缓存
12
- *
13
- * @author ruoyi
14
- */
15
-public class RedisClientDetailsService extends JdbcClientDetailsService
16
-{
17
-    public RedisClientDetailsService(DataSource dataSource)
18
-    {
19
-        super(dataSource);
20
-        super.setSelectClientDetailsSql(SecurityConstants.DEFAULT_SELECT_STATEMENT);
21
-        super.setFindClientDetailsSql(SecurityConstants.DEFAULT_FIND_STATEMENT);
22
-    }
23
-
24
-    @Override
25
-    @Cacheable(value = CacheConstants.CLIENT_DETAILS_KEY, key = "#clientId", unless = "#result == null")
26
-    public ClientDetails loadClientByClientId(String clientId)
27
-    {
28
-        return super.loadClientByClientId(clientId);
29
-    }
30
-}

+ 123 - 0
ruoyi-common/ruoyi-common-security/src/main/java/com/ruoyi/common/security/service/TokenService.java

@@ -0,0 +1,123 @@
1
+package com.ruoyi.common.security.service;
2
+
3
+import java.util.HashMap;
4
+import java.util.Map;
5
+import java.util.concurrent.TimeUnit;
6
+import javax.servlet.http.HttpServletRequest;
7
+import org.apache.commons.lang3.StringUtils;
8
+import org.springframework.beans.factory.annotation.Autowired;
9
+import org.springframework.stereotype.Component;
10
+import com.ruoyi.common.core.constant.CacheConstants;
11
+import com.ruoyi.common.core.constant.Constants;
12
+import com.ruoyi.common.core.utils.IdUtils;
13
+import com.ruoyi.common.core.utils.ServletUtils;
14
+import com.ruoyi.common.redis.service.RedisService;
15
+import com.ruoyi.system.api.model.LoginUser;
16
+
17
+/**
18
+ * token验证处理
19
+ * 
20
+ * @author ruoyi
21
+ */
22
+@Component
23
+public class TokenService
24
+{
25
+    @Autowired
26
+    private RedisService redisService;
27
+
28
+    private final static long EXPIRE_TIME = Constants.TOKEN_EXPIRE * 60;
29
+
30
+    private final static String ACCESS_TOKEN = CacheConstants.LOGIN_TOKEN_KEY;
31
+
32
+    protected static final long MILLIS_SECOND = 1000;
33
+
34
+    /**
35
+     * 创建令牌
36
+     */
37
+    public Map<String, Object> createToken(LoginUser loginUser)
38
+    {
39
+        // 生成token
40
+        String token = IdUtils.fastUUID();
41
+        loginUser.setToken(token);
42
+        loginUser.setUserid(loginUser.getSysUser().getUserId());
43
+        loginUser.setUsername(loginUser.getSysUser().getUserName());
44
+        refreshToken(loginUser);
45
+
46
+        // 保存或更新用户token
47
+        Map<String, Object> map = new HashMap<String, Object>();
48
+        map.put("access_token", token);
49
+        map.put("expires_in", EXPIRE_TIME);
50
+        redisService.setCacheObject(ACCESS_TOKEN + token, loginUser, EXPIRE_TIME, TimeUnit.SECONDS);
51
+        return map;
52
+    }
53
+
54
+    /**
55
+     * 获取用户身份信息
56
+     *
57
+     * @return 用户信息
58
+     */
59
+    public LoginUser getLoginUser()
60
+    {
61
+        return getLoginUser(ServletUtils.getRequest());
62
+    }
63
+
64
+    /**
65
+     * 获取用户身份信息
66
+     *
67
+     * @return 用户信息
68
+     */
69
+    public LoginUser getLoginUser(HttpServletRequest request)
70
+    {
71
+        // 获取请求携带的令牌
72
+        String token = getToken(request);
73
+        if (StringUtils.isNotEmpty(token))
74
+        {
75
+            String userKey = getTokenKey(token);
76
+            LoginUser user = redisService.getCacheObject(userKey);
77
+            return user;
78
+        }
79
+        return null;
80
+    }
81
+
82
+    public void delLoginUser(String token)
83
+    {
84
+        if (StringUtils.isNotEmpty(token))
85
+        {
86
+            String userKey = getTokenKey(token);
87
+            redisService.deleteObject(userKey);
88
+        }
89
+    }
90
+
91
+    /**
92
+     * 刷新令牌有效期
93
+     *
94
+     * @param loginUser 登录信息
95
+     */
96
+    public Long refreshToken(LoginUser loginUser)
97
+    {
98
+        loginUser.setLoginTime(System.currentTimeMillis());
99
+        loginUser.setExpireTime(loginUser.getLoginTime() + EXPIRE_TIME * MILLIS_SECOND);
100
+        // 根据uuid将loginUser缓存
101
+        String userKey = getTokenKey(loginUser.getToken());
102
+        redisService.setCacheObject(userKey, loginUser, EXPIRE_TIME, TimeUnit.SECONDS);
103
+        return EXPIRE_TIME;
104
+    }
105
+
106
+    private String getTokenKey(String token)
107
+    {
108
+        return ACCESS_TOKEN + token;
109
+    }
110
+
111
+    /**
112
+     * 获取请求token
113
+     */
114
+    private String getToken(HttpServletRequest request)
115
+    {
116
+        String token = request.getHeader(CacheConstants.HEADER);
117
+        if (StringUtils.isNotEmpty(token) && token.startsWith(CacheConstants.TOKEN_PREFIX))
118
+        {
119
+            token = token.replace(CacheConstants.TOKEN_PREFIX, "");
120
+        }
121
+        return token;
122
+    }
123
+}

+ 0 - 83
ruoyi-common/ruoyi-common-security/src/main/java/com/ruoyi/common/security/service/UserDetailsServiceImpl.java

@@ -1,83 +0,0 @@
1
-package com.ruoyi.common.security.service;
2
-
3
-import java.util.Collection;
4
-import java.util.HashSet;
5
-import java.util.Set;
6
-import org.slf4j.Logger;
7
-import org.slf4j.LoggerFactory;
8
-import org.springframework.beans.factory.annotation.Autowired;
9
-import org.springframework.security.core.GrantedAuthority;
10
-import org.springframework.security.core.authority.AuthorityUtils;
11
-import org.springframework.security.core.userdetails.UserDetails;
12
-import org.springframework.security.core.userdetails.UserDetailsService;
13
-import org.springframework.security.core.userdetails.UsernameNotFoundException;
14
-import org.springframework.stereotype.Service;
15
-import com.ruoyi.common.core.domain.R;
16
-import com.ruoyi.common.core.enums.UserStatus;
17
-import com.ruoyi.common.core.exception.BaseException;
18
-import com.ruoyi.common.core.utils.StringUtils;
19
-import com.ruoyi.common.security.domain.LoginUser;
20
-import com.ruoyi.system.api.RemoteUserService;
21
-import com.ruoyi.system.api.domain.SysUser;
22
-import com.ruoyi.system.api.model.UserInfo;
23
-
24
-/**
25
- * 用户信息处理
26
- *
27
- * @author ruoyi
28
- */
29
-@Service
30
-public class UserDetailsServiceImpl implements UserDetailsService
31
-{
32
-    private static final Logger log = LoggerFactory.getLogger(UserDetailsServiceImpl.class);
33
-
34
-    @Autowired
35
-    private RemoteUserService remoteUserService;
36
-
37
-    @Override
38
-    public UserDetails loadUserByUsername(String username)
39
-    {
40
-        R<UserInfo> userResult = remoteUserService.getUserInfo(username);
41
-        checkUser(userResult, username);
42
-        return getUserDetails(userResult);
43
-    }
44
-
45
-    public void checkUser(R<UserInfo> userResult, String username)
46
-    {
47
-        if (StringUtils.isNull(userResult) || StringUtils.isNull(userResult.getData()))
48
-        {
49
-            log.info("登录用户:{} 不存在.", username);
50
-            throw new UsernameNotFoundException("登录用户:" + username + " 不存在");
51
-        }
52
-        else if (UserStatus.DELETED.getCode().equals(userResult.getData().getSysUser().getDelFlag()))
53
-        {
54
-            log.info("登录用户:{} 已被删除.", username);
55
-            throw new BaseException("对不起,您的账号:" + username + " 已被删除");
56
-        }
57
-        else if (UserStatus.DISABLE.getCode().equals(userResult.getData().getSysUser().getStatus()))
58
-        {
59
-            log.info("登录用户:{} 已被停用.", username);
60
-            throw new BaseException("对不起,您的账号:" + username + " 已停用");
61
-        }
62
-    }
63
-
64
-    private UserDetails getUserDetails(R<UserInfo> result)
65
-    {
66
-        UserInfo info = result.getData();
67
-        Set<String> dbAuthsSet = new HashSet<String>();
68
-        if (StringUtils.isNotEmpty(info.getRoles()))
69
-        {
70
-            // 获取角色
71
-            dbAuthsSet.addAll(info.getRoles());
72
-            // 获取权限
73
-            dbAuthsSet.addAll(info.getPermissions());
74
-        }
75
-
76
-        Collection<? extends GrantedAuthority> authorities = AuthorityUtils
77
-                .createAuthorityList(dbAuthsSet.toArray(new String[0]));
78
-        SysUser user = info.getSysUser();
79
-
80
-        return new LoginUser(user.getUserId(), user.getUserName(), user.getPassword(), true, true, true, true,
81
-                authorities);
82
-    }
83
-}

+ 13 - 39
ruoyi-common/ruoyi-common-security/src/main/java/com/ruoyi/common/security/utils/SecurityUtils.java

@@ -1,9 +1,9 @@
1 1
 package com.ruoyi.common.security.utils;
2 2
 
3
-import org.springframework.security.core.Authentication;
4
-import org.springframework.security.core.context.SecurityContextHolder;
5 3
 import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
6
-import com.ruoyi.common.security.domain.LoginUser;
4
+import com.ruoyi.common.core.constant.CacheConstants;
5
+import com.ruoyi.common.core.text.Convert;
6
+import com.ruoyi.common.core.utils.ServletUtils;
7 7
 
8 8
 /**
9 9
  * 权限获取工具类
@@ -13,45 +13,30 @@ import com.ruoyi.common.security.domain.LoginUser;
13 13
 public class SecurityUtils
14 14
 {
15 15
     /**
16
-     * 获取Authentication
17
-     */
18
-    public static Authentication getAuthentication()
19
-    {
20
-        return SecurityContextHolder.getContext().getAuthentication();
21
-    }
22
-
23
-    /**
24 16
      * 获取用户
25 17
      */
26 18
     public static String getUsername()
27 19
     {
28
-        return getLoginUser().getUsername();
20
+        return ServletUtils.getRequest().getHeader(CacheConstants.DETAILS_USERNAME);
29 21
     }
30 22
 
31 23
     /**
32
-     * 获取用户
24
+     * 获取用户ID
33 25
      */
34
-    public static LoginUser getLoginUser(Authentication authentication)
26
+    public static Long getUserId()
35 27
     {
36
-        Object principal = authentication.getPrincipal();
37
-        if (principal instanceof LoginUser)
38
-        {
39
-            return (LoginUser) principal;
40
-        }
41
-        return null;
28
+        return Convert.toLong(ServletUtils.getRequest().getHeader(CacheConstants.DETAILS_USER_ID));
42 29
     }
43 30
 
44 31
     /**
45
-     * 获取用户
32
+     * 是否为管理员
33
+     * 
34
+     * @param userId 用户ID
35
+     * @return 结果
46 36
      */
47
-    public static LoginUser getLoginUser()
37
+    public static boolean isAdmin(Long userId)
48 38
     {
49
-        Authentication authentication = getAuthentication();
50
-        if (authentication == null)
51
-        {
52
-            return null;
53
-        }
54
-        return getLoginUser(authentication);
39
+        return userId != null && 1L == userId;
55 40
     }
56 41
 
57 42
     /**
@@ -78,15 +63,4 @@ public class SecurityUtils
78 63
         BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
79 64
         return passwordEncoder.matches(rawPassword, encodedPassword);
80 65
     }
81
-
82
-    /**
83
-     * 是否为管理员
84
-     * 
85
-     * @param userId 用户ID
86
-     * @return 结果
87
-     */
88
-    public static boolean isAdmin(Long userId)
89
-    {
90
-        return userId != null && 1L == userId;
91
-    }
92 66
 }

+ 2 - 6
ruoyi-common/ruoyi-common-security/src/main/resources/META-INF/spring.factories

@@ -1,8 +1,4 @@
1 1
 org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
2
-  com.ruoyi.common.security.service.UserDetailsServiceImpl,\
3
-  com.ruoyi.common.security.service.PermissionService,\
4
-  com.ruoyi.common.security.config.MethodSecurityConfig,\
5
-  com.ruoyi.common.security.handler.CustomAccessDeniedHandler,\
2
+  com.ruoyi.common.security.service.TokenService,\
3
+  com.ruoyi.common.security.aspect.PreAuthorizeAspect,\
6 4
   com.ruoyi.common.security.handler.GlobalExceptionHandler
7
-
8
-  

+ 35 - 38
ruoyi-common/ruoyi-common-swagger/src/main/java/com/ruoyi/common/swagger/config/SwaggerAutoConfiguration.java

@@ -2,7 +2,6 @@ package com.ruoyi.common.swagger.config;
2 2
 
3 3
 import java.util.ArrayList;
4 4
 import java.util.Arrays;
5
-import java.util.Collections;
6 5
 import java.util.List;
7 6
 import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
8 7
 import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
@@ -15,11 +14,9 @@ import springfox.documentation.builders.ApiInfoBuilder;
15 14
 import springfox.documentation.builders.PathSelectors;
16 15
 import springfox.documentation.builders.RequestHandlerSelectors;
17 16
 import springfox.documentation.service.ApiInfo;
17
+import springfox.documentation.service.ApiKey;
18 18
 import springfox.documentation.service.AuthorizationScope;
19 19
 import springfox.documentation.service.Contact;
20
-import springfox.documentation.service.GrantType;
21
-import springfox.documentation.service.OAuth;
22
-import springfox.documentation.service.ResourceOwnerPasswordCredentialsGrant;
23 20
 import springfox.documentation.service.SecurityReference;
24 21
 import springfox.documentation.spi.DocumentationType;
25 22
 import springfox.documentation.spi.service.contexts.SecurityContext;
@@ -66,54 +63,55 @@ public class SwaggerAutoConfiguration
66 63
         List<Predicate<String>> excludePath = new ArrayList<>();
67 64
         swaggerProperties.getExcludePath().forEach(path -> excludePath.add(PathSelectors.ant(path)));
68 65
 
69
-         //noinspection Guava
66
+        //noinspection Guava
70 67
         return new Docket(DocumentationType.SWAGGER_2)
71 68
                 .host(swaggerProperties.getHost())
72 69
                 .apiInfo(apiInfo(swaggerProperties)).select()
73 70
                 .apis(RequestHandlerSelectors.basePackage(swaggerProperties.getBasePackage()))
74 71
                 .paths(Predicates.and(Predicates.not(Predicates.or(excludePath)), Predicates.or(basePath)))
75 72
                 .build()
76
-                .securitySchemes(Collections.singletonList(securitySchema()))
77
-                .securityContexts(Collections.singletonList(securityContext()))
73
+                .securitySchemes(securitySchemes())
74
+                .securityContexts(securityContexts())
78 75
                 .pathMapping("/");
79 76
     }
80 77
 
81
-     /**
82
-      * 配置默认的全局鉴权策略的开关,通过正则表达式进行匹配;默认匹配所有URL
83
-      *
84
-      * @return
85
-      */
86
-    private SecurityContext securityContext()
78
+    /**
79
+     * 安全模式,这里指定token通过Authorization头请求头传递
80
+     */
81
+    private List<ApiKey> securitySchemes()
87 82
     {
88
-         return SecurityContext.builder()
89
-             .securityReferences(defaultAuth())
90
-             .forPaths(PathSelectors.regex(swaggerProperties().getAuthorization().getAuthRegex()))
91
-             .build();
83
+        List<ApiKey> apiKeyList = new ArrayList<ApiKey>();
84
+        apiKeyList.add(new ApiKey("Authorization", "Authorization", "header"));
85
+        return apiKeyList;
92 86
     }
93 87
 
94
-     /**
95
-      * 默认的全局鉴权策略
96
-      *
97
-      * @return
98
-      */
99
-    private List<SecurityReference> defaultAuth()
88
+    /**
89
+     * 安全上下文
90
+     */
91
+    private List<SecurityContext> securityContexts()
100 92
     {
101
-         ArrayList<AuthorizationScope> authorizationScopeList = new ArrayList<>();
102
-         swaggerProperties().getAuthorization().getAuthorizationScopeList().forEach(authorizationScope -> authorizationScopeList.add(new AuthorizationScope(authorizationScope.getScope(), authorizationScope.getDescription())));
103
-         AuthorizationScope[] authorizationScopes = new AuthorizationScope[authorizationScopeList.size()];
104
-         return Collections.singletonList(SecurityReference.builder()
105
-             .reference(swaggerProperties().getAuthorization().getName())
106
-             .scopes(authorizationScopeList.toArray(authorizationScopes))
107
-             .build());
93
+        List<SecurityContext> securityContexts = new ArrayList<>();
94
+        securityContexts.add(
95
+                SecurityContext.builder()
96
+                        .securityReferences(defaultAuth())
97
+                        .forPaths(PathSelectors.regex("^(?!auth).*$"))
98
+                        .build());
99
+        return securityContexts;
108 100
     }
109 101
 
110
-    private OAuth securitySchema()
102
+    /**
103
+     * 默认的全局鉴权策略
104
+     *
105
+     * @return
106
+     */
107
+    private List<SecurityReference> defaultAuth()
111 108
     {
112
-        ArrayList<AuthorizationScope> authorizationScopeList = new ArrayList<>();
113
-        swaggerProperties().getAuthorization().getAuthorizationScopeList().forEach(authorizationScope -> authorizationScopeList.add(new AuthorizationScope(authorizationScope.getScope(), authorizationScope.getDescription())));
114
-        ArrayList<GrantType> grantTypes = new ArrayList<>();
115
-        swaggerProperties().getAuthorization().getTokenUrlList().forEach(tokenUrl -> grantTypes.add(new ResourceOwnerPasswordCredentialsGrant(tokenUrl)));
116
-        return new OAuth(swaggerProperties().getAuthorization().getName(), authorizationScopeList, grantTypes);
109
+        AuthorizationScope authorizationScope = new AuthorizationScope("global", "accessEverything");
110
+        AuthorizationScope[] authorizationScopes = new AuthorizationScope[1];
111
+        authorizationScopes[0] = authorizationScope;
112
+        List<SecurityReference> securityReferences = new ArrayList<>();
113
+        securityReferences.add(new SecurityReference("Authorization", authorizationScopes));
114
+        return securityReferences;
117 115
     }
118 116
 
119 117
     private ApiInfo apiInfo(SwaggerProperties swaggerProperties)
@@ -128,5 +126,4 @@ public class SwaggerAutoConfiguration
128 126
              .version(swaggerProperties.getVersion())
129 127
              .build();
130 128
     }
131
- }
132
-
129
+}

+ 108 - 0
ruoyi-gateway/src/main/java/com/ruoyi/gateway/filter/AuthFilter.java

@@ -0,0 +1,108 @@
1
+package com.ruoyi.gateway.filter;
2
+
3
+import java.util.Arrays;
4
+import javax.annotation.Resource;
5
+import org.slf4j.Logger;
6
+import org.slf4j.LoggerFactory;
7
+import org.springframework.cloud.gateway.filter.GatewayFilterChain;
8
+import org.springframework.cloud.gateway.filter.GlobalFilter;
9
+import org.springframework.core.Ordered;
10
+import org.springframework.core.io.buffer.DataBufferFactory;
11
+import org.springframework.data.redis.core.ValueOperations;
12
+import org.springframework.http.HttpStatus;
13
+import org.springframework.http.MediaType;
14
+import org.springframework.http.server.reactive.ServerHttpRequest;
15
+import org.springframework.http.server.reactive.ServerHttpResponse;
16
+import org.springframework.stereotype.Component;
17
+import org.springframework.web.server.ServerWebExchange;
18
+import com.alibaba.fastjson.JSON;
19
+import com.alibaba.fastjson.JSONObject;
20
+import com.ruoyi.common.core.constant.CacheConstants;
21
+import com.ruoyi.common.core.domain.R;
22
+import com.ruoyi.common.core.utils.StringUtils;
23
+import reactor.core.publisher.Mono;
24
+
25
+/**
26
+ * 网关鉴权
27
+ * 
28
+ * @author ruoyi
29
+ */
30
+@Component
31
+public class AuthFilter implements GlobalFilter, Ordered
32
+{
33
+    private static final Logger log = LoggerFactory.getLogger(AuthFilter.class);
34
+
35
+    // 排除过滤的 uri 地址,swagger排除自行添加
36
+    private static final String[] whiteList = { "/auth/login", "/code/v2/api-docs", "/schedule/v2/api-docs",
37
+            "/system/v2/api-docs", "/csrf" };
38
+
39
+    @Resource(name = "stringRedisTemplate")
40
+    private ValueOperations<String, String> sops;
41
+
42
+    @Override
43
+    public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain)
44
+    {
45
+        String url = exchange.getRequest().getURI().getPath();
46
+        // 跳过不需要验证的路径
47
+        if (Arrays.asList(whiteList).contains(url))
48
+        {
49
+            return chain.filter(exchange);
50
+        }
51
+        String token = getToken(exchange.getRequest());
52
+        if (StringUtils.isBlank(token))
53
+        {
54
+            return setUnauthorizedResponse(exchange, "令牌不能为空");
55
+        }
56
+        String userStr = sops.get(CacheConstants.LOGIN_TOKEN_KEY + token);
57
+        if (StringUtils.isNull(userStr))
58
+        {
59
+            return setUnauthorizedResponse(exchange, "令牌验证失败");
60
+        }
61
+        JSONObject obj = JSONObject.parseObject(userStr);
62
+        String userid = obj.getString("userid");
63
+        String username = obj.getString("username");
64
+        if (StringUtils.isBlank(userid) || StringUtils.isBlank(username))
65
+        {
66
+            return setUnauthorizedResponse(exchange, "令牌验证失败");
67
+        }
68
+        // 设置用户信息到请求
69
+        ServerHttpRequest mutableReq = exchange.getRequest().mutate().header(CacheConstants.DETAILS_USER_ID, userid)
70
+                .header(CacheConstants.DETAILS_USERNAME, username).build();
71
+        ServerWebExchange mutableExchange = exchange.mutate().request(mutableReq).build();
72
+        
73
+        return chain.filter(mutableExchange);
74
+    }
75
+
76
+    private Mono<Void> setUnauthorizedResponse(ServerWebExchange exchange, String msg)
77
+    {
78
+        ServerHttpResponse response = exchange.getResponse();
79
+        response.getHeaders().setContentType(MediaType.APPLICATION_JSON);
80
+        response.setStatusCode(HttpStatus.OK);
81
+
82
+        log.error("[鉴权异常处理]请求路径:{}", exchange.getRequest().getPath());
83
+
84
+        return response.writeWith(Mono.fromSupplier(() -> {
85
+            DataBufferFactory bufferFactory = response.bufferFactory();
86
+            return bufferFactory.wrap(JSON.toJSONBytes(R.fail(msg)));
87
+        }));
88
+    }
89
+
90
+    /**
91
+     * 获取请求token
92
+     */
93
+    private String getToken(ServerHttpRequest request)
94
+    {
95
+        String token = request.getHeaders().getFirst(CacheConstants.HEADER);
96
+        if (StringUtils.isNotEmpty(token) && token.startsWith(CacheConstants.TOKEN_PREFIX))
97
+        {
98
+            token = token.replace(CacheConstants.TOKEN_PREFIX, "");
99
+        }
100
+        return token;
101
+    }
102
+
103
+    @Override
104
+    public int getOrder()
105
+    {
106
+        return -200;
107
+    }
108
+}

+ 100 - 0
ruoyi-gateway/src/main/java/com/ruoyi/gateway/filter/CacheRequestFilter.java

@@ -0,0 +1,100 @@
1
+package com.ruoyi.gateway.filter;
2
+
3
+import java.util.Collections;
4
+import java.util.List;
5
+import org.springframework.cloud.gateway.filter.GatewayFilter;
6
+import org.springframework.cloud.gateway.filter.GatewayFilterChain;
7
+import org.springframework.cloud.gateway.filter.OrderedGatewayFilter;
8
+import org.springframework.cloud.gateway.filter.factory.AbstractGatewayFilterFactory;
9
+import org.springframework.core.io.buffer.DataBuffer;
10
+import org.springframework.core.io.buffer.DataBufferFactory;
11
+import org.springframework.core.io.buffer.DataBufferUtils;
12
+import org.springframework.http.HttpMethod;
13
+import org.springframework.http.server.reactive.ServerHttpRequestDecorator;
14
+import org.springframework.stereotype.Component;
15
+import org.springframework.web.server.ServerWebExchange;
16
+import reactor.core.publisher.Flux;
17
+import reactor.core.publisher.Mono;
18
+
19
+@Component
20
+public class CacheRequestFilter extends AbstractGatewayFilterFactory<CacheRequestFilter.Config>
21
+{
22
+    public CacheRequestFilter()
23
+    {
24
+        super(Config.class);
25
+    }
26
+
27
+    @Override
28
+    public String name()
29
+    {
30
+        return "CacheRequestFilter";
31
+    }
32
+
33
+    @Override
34
+    public GatewayFilter apply(Config config)
35
+    {
36
+        CacheRequestGatewayFilter cacheRequestGatewayFilter = new CacheRequestGatewayFilter();
37
+        Integer order = config.getOrder();
38
+        if (order == null)
39
+        {
40
+            return cacheRequestGatewayFilter;
41
+        }
42
+        return new OrderedGatewayFilter(cacheRequestGatewayFilter, order);
43
+    }
44
+
45
+    public static class CacheRequestGatewayFilter implements GatewayFilter
46
+    {
47
+        @Override
48
+        public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain)
49
+        {
50
+            // GET DELETE 不过滤
51
+            HttpMethod method = exchange.getRequest().getMethod();
52
+            if (method == null || method.matches("GET") || method.matches("DELETE"))
53
+            {
54
+                return chain.filter(exchange);
55
+            }
56
+            return DataBufferUtils.join(exchange.getRequest().getBody()).map(dataBuffer -> {
57
+                byte[] bytes = new byte[dataBuffer.readableByteCount()];
58
+                dataBuffer.read(bytes);
59
+                DataBufferUtils.release(dataBuffer);
60
+                return bytes;
61
+            }).defaultIfEmpty(new byte[0]).flatMap(bytes -> {
62
+                DataBufferFactory dataBufferFactory = exchange.getResponse().bufferFactory();
63
+                ServerHttpRequestDecorator decorator = new ServerHttpRequestDecorator(exchange.getRequest())
64
+                {
65
+                    @Override
66
+                    public Flux<DataBuffer> getBody()
67
+                    {
68
+                        if (bytes.length > 0)
69
+                        {
70
+                            return Flux.just(dataBufferFactory.wrap(bytes));
71
+                        }
72
+                        return Flux.empty();
73
+                    }
74
+                };
75
+                return chain.filter(exchange.mutate().request(decorator).build());
76
+            });
77
+        }
78
+    }
79
+
80
+    @Override
81
+    public List<String> shortcutFieldOrder()
82
+    {
83
+        return Collections.singletonList("order");
84
+    }
85
+
86
+    static class Config
87
+    {
88
+        private Integer order;
89
+
90
+        public Integer getOrder()
91
+        {
92
+            return order;
93
+        }
94
+
95
+        public void setOrder(Integer order)
96
+        {
97
+            this.order = order;
98
+        }
99
+    }
100
+}

+ 24 - 24
ruoyi-gateway/src/main/java/com/ruoyi/gateway/filter/ValidateCodeFilter.java

@@ -1,16 +1,22 @@
1 1
 package com.ruoyi.gateway.filter;
2 2
 
3
+import java.nio.CharBuffer;
4
+import java.nio.charset.StandardCharsets;
5
+import java.util.concurrent.atomic.AtomicReference;
3 6
 import org.springframework.beans.factory.annotation.Autowired;
4 7
 import org.springframework.cloud.gateway.filter.GatewayFilter;
5 8
 import org.springframework.cloud.gateway.filter.factory.AbstractGatewayFilterFactory;
6
-import org.springframework.http.HttpHeaders;
9
+import org.springframework.core.io.buffer.DataBuffer;
10
+import org.springframework.core.io.buffer.DataBufferUtils;
7 11
 import org.springframework.http.server.reactive.ServerHttpRequest;
8 12
 import org.springframework.http.server.reactive.ServerHttpResponse;
9 13
 import org.springframework.stereotype.Component;
10 14
 import com.alibaba.fastjson.JSON;
15
+import com.alibaba.fastjson.JSONObject;
11 16
 import com.ruoyi.common.core.utils.StringUtils;
12 17
 import com.ruoyi.common.core.web.domain.AjaxResult;
13 18
 import com.ruoyi.gateway.service.ValidateCodeService;
19
+import reactor.core.publisher.Flux;
14 20
 import reactor.core.publisher.Mono;
15 21
 
16 22
 /**
@@ -21,20 +27,14 @@ import reactor.core.publisher.Mono;
21 27
 @Component
22 28
 public class ValidateCodeFilter extends AbstractGatewayFilterFactory<Object>
23 29
 {
24
-    private final static String AUTH_URL = "/oauth/token";
30
+    private final static String AUTH_URL = "/auth/login";
25 31
 
26 32
     @Autowired
27 33
     private ValidateCodeService validateCodeService;
28 34
 
29
-    private static final String BASIC_ = "Basic ";
30
-
31 35
     private static final String CODE = "code";
32 36
 
33 37
     private static final String UUID = "uuid";
34
-    
35
-    private static final String GRANT_TYPE = "grant_type";
36
-    
37
-    private static final String REFRESH_TOKEN = "refresh_token";
38 38
 
39 39
     @Override
40 40
     public GatewayFilter apply(Object config)
@@ -47,25 +47,12 @@ public class ValidateCodeFilter extends AbstractGatewayFilterFactory<Object>
47 47
             {
48 48
                 return chain.filter(exchange);
49 49
             }
50
-            
51
-            // 刷新token请求,不处理
52
-            String grantType = request.getQueryParams().getFirst(GRANT_TYPE);
53
-            if (StringUtils.containsIgnoreCase(request.getURI().getPath(), AUTH_URL) && StringUtils.containsIgnoreCase(grantType, REFRESH_TOKEN))
54
-            {
55
-                return chain.filter(exchange);
56
-            }
57 50
 
58
-            // 消息头存在内容,且不存在验证码参数,不处理
59
-            String header = request.getHeaders().getFirst(HttpHeaders.AUTHORIZATION);
60
-            if (StringUtils.isNotEmpty(header) && StringUtils.startsWith(header, BASIC_)
61
-                    && !request.getQueryParams().containsKey(CODE) && !request.getQueryParams().containsKey(UUID))
62
-            {
63
-                return chain.filter(exchange);
64
-            }
65 51
             try
66 52
             {
67
-                validateCodeService.checkCapcha(request.getQueryParams().getFirst(CODE),
68
-                        request.getQueryParams().getFirst(UUID));
53
+                String rspStr = resolveBodyFromRequest(request);
54
+                JSONObject obj = JSONObject.parseObject(rspStr);
55
+                validateCodeService.checkCapcha(obj.getString(CODE), obj.getString(UUID));
69 56
             }
70 57
             catch (Exception e)
71 58
             {
@@ -77,4 +64,17 @@ public class ValidateCodeFilter extends AbstractGatewayFilterFactory<Object>
77 64
             return chain.filter(exchange);
78 65
         };
79 66
     }
67
+
68
+    private String resolveBodyFromRequest(ServerHttpRequest serverHttpRequest)
69
+    {
70
+        // 获取请求体
71
+        Flux<DataBuffer> body = serverHttpRequest.getBody();
72
+        AtomicReference<String> bodyRef = new AtomicReference<>();
73
+        body.subscribe(buffer -> {
74
+            CharBuffer charBuffer = StandardCharsets.UTF_8.decode(buffer.asByteBuffer());
75
+            DataBufferUtils.release(buffer);
76
+            bodyRef.set(charBuffer.toString());
77
+        });
78
+        return bodyRef.get();
79
+    }
80 80
 }

+ 2 - 2
ruoyi-modules/ruoyi-gen/pom.xml

@@ -35,10 +35,10 @@
35 35
             <artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
36 36
         </dependency>
37 37
         
38
-        <!-- SpringBoot Web -->
38
+        <!-- SpringBoot Actuator -->
39 39
         <dependency>
40 40
             <groupId>org.springframework.boot</groupId>
41
-            <artifactId>spring-boot-starter-web</artifactId>
41
+            <artifactId>spring-boot-starter-actuator</artifactId>
42 42
         </dependency>
43 43
 		
44 44
         <!-- Swagger -->

+ 11 - 12
ruoyi-modules/ruoyi-gen/src/main/java/com/ruoyi/gen/controller/GenController.java

@@ -7,7 +7,6 @@ import java.util.Map;
7 7
 import javax.servlet.http.HttpServletResponse;
8 8
 import org.apache.commons.io.IOUtils;
9 9
 import org.springframework.beans.factory.annotation.Autowired;
10
-import org.springframework.security.access.prepost.PreAuthorize;
11 10
 import org.springframework.validation.annotation.Validated;
12 11
 import org.springframework.web.bind.annotation.DeleteMapping;
13 12
 import org.springframework.web.bind.annotation.GetMapping;
@@ -23,6 +22,7 @@ import com.ruoyi.common.core.web.domain.AjaxResult;
23 22
 import com.ruoyi.common.core.web.page.TableDataInfo;
24 23
 import com.ruoyi.common.log.annotation.Log;
25 24
 import com.ruoyi.common.log.enums.BusinessType;
25
+import com.ruoyi.common.security.annotation.PreAuthorize;
26 26
 import com.ruoyi.gen.domain.GenTable;
27 27
 import com.ruoyi.gen.domain.GenTableColumn;
28 28
 import com.ruoyi.gen.service.IGenTableColumnService;
@@ -46,7 +46,7 @@ public class GenController extends BaseController
46 46
     /**
47 47
      * 查询代码生成列表
48 48
      */
49
-    @PreAuthorize("@ss.hasPermi('tool:gen:list')")
49
+    @PreAuthorize(hasPermi = "tool:gen:list")
50 50
     @GetMapping("/list")
51 51
     public TableDataInfo genList(GenTable genTable)
52 52
     {
@@ -58,7 +58,7 @@ public class GenController extends BaseController
58 58
     /**
59 59
      * 修改代码生成业务
60 60
      */
61
-    @PreAuthorize("@ss.hasPermi('tool:gen:query')")
61
+    @PreAuthorize(hasPermi = "tool:gen:query")
62 62
     @GetMapping(value = "/{talbleId}")
63 63
     public AjaxResult getInfo(@PathVariable Long talbleId)
64 64
     {
@@ -73,7 +73,7 @@ public class GenController extends BaseController
73 73
     /**
74 74
      * 查询数据库列表
75 75
      */
76
-    @PreAuthorize("@ss.hasPermi('tool:gen:list')")
76
+    @PreAuthorize(hasPermi = "tool:gen:list")
77 77
     @GetMapping("/db/list")
78 78
     public TableDataInfo dataList(GenTable genTable)
79 79
     {
@@ -85,7 +85,6 @@ public class GenController extends BaseController
85 85
     /**
86 86
      * 查询数据表字段列表
87 87
      */
88
-    @PreAuthorize("@ss.hasPermi('tool:gen:list')")
89 88
     @GetMapping(value = "/column/{talbleId}")
90 89
     public TableDataInfo columnList(Long tableId)
91 90
     {
@@ -99,7 +98,7 @@ public class GenController extends BaseController
99 98
     /**
100 99
      * 导入表结构(保存)
101 100
      */
102
-    @PreAuthorize("@ss.hasPermi('tool:gen:list')")
101
+    @PreAuthorize(hasPermi = "tool:gen:list")
103 102
     @Log(title = "代码生成", businessType = BusinessType.IMPORT)
104 103
     @PostMapping("/importTable")
105 104
     public AjaxResult importTableSave(String tables)
@@ -114,7 +113,7 @@ public class GenController extends BaseController
114 113
     /**
115 114
      * 修改保存代码生成业务
116 115
      */
117
-    @PreAuthorize("@ss.hasPermi('tool:gen:edit')")
116
+    @PreAuthorize(hasPermi = "tool:gen:edit")
118 117
     @Log(title = "代码生成", businessType = BusinessType.UPDATE)
119 118
     @PutMapping
120 119
     public AjaxResult editSave(@Validated @RequestBody GenTable genTable)
@@ -127,7 +126,7 @@ public class GenController extends BaseController
127 126
     /**
128 127
      * 删除代码生成
129 128
      */
130
-    @PreAuthorize("@ss.hasPermi('tool:gen:remove')")
129
+    @PreAuthorize(hasPermi = "tool:gen:remove")
131 130
     @Log(title = "代码生成", businessType = BusinessType.DELETE)
132 131
     @DeleteMapping("/{tableIds}")
133 132
     public AjaxResult remove(@PathVariable Long[] tableIds)
@@ -139,7 +138,7 @@ public class GenController extends BaseController
139 138
     /**
140 139
      * 预览代码
141 140
      */
142
-    @PreAuthorize("@ss.hasPermi('tool:gen:preview')")
141
+    @PreAuthorize(hasPermi = "tool:gen:preview")
143 142
     @GetMapping("/preview/{tableId}")
144 143
     public AjaxResult preview(@PathVariable("tableId") Long tableId) throws IOException
145 144
     {
@@ -150,7 +149,7 @@ public class GenController extends BaseController
150 149
     /**
151 150
      * 生成代码(下载方式)
152 151
      */
153
-    @PreAuthorize("@ss.hasPermi('tool:gen:code')")
152
+    @PreAuthorize(hasPermi = "tool:gen:code")
154 153
     @Log(title = "代码生成", businessType = BusinessType.GENCODE)
155 154
     @GetMapping("/download/{tableName}")
156 155
     public void download(HttpServletResponse response, @PathVariable("tableName") String tableName) throws IOException
@@ -162,7 +161,7 @@ public class GenController extends BaseController
162 161
     /**
163 162
      * 生成代码(自定义路径)
164 163
      */
165
-    @PreAuthorize("@ss.hasPermi('tool:gen:code')")
164
+    @PreAuthorize(hasPermi = "tool:gen:code")
166 165
     @Log(title = "代码生成", businessType = BusinessType.GENCODE)
167 166
     @GetMapping("/genCode/{tableName}")
168 167
     public AjaxResult genCode(HttpServletResponse response, @PathVariable("tableName") String tableName)
@@ -174,7 +173,7 @@ public class GenController extends BaseController
174 173
     /**
175 174
      * 批量生成代码
176 175
      */
177
-    @PreAuthorize("@ss.hasPermi('tool:gen:code')")
176
+    @PreAuthorize(hasPermi = "tool:gen:code")
178 177
     @Log(title = "代码生成", businessType = BusinessType.GENCODE)
179 178
     @GetMapping("/batchGenCode")
180 179
     public void batchGenCode(HttpServletResponse response, String tables) throws IOException

+ 7 - 7
ruoyi-modules/ruoyi-gen/src/main/resources/vm/java/controller.java.vm

@@ -3,7 +3,6 @@ package ${packageName}.controller;
3 3
 import java.util.List;
4 4
 import java.io.IOException;
5 5
 import javax.servlet.http.HttpServletResponse;
6
-import org.springframework.security.access.prepost.PreAuthorize;
7 6
 import org.springframework.beans.factory.annotation.Autowired;
8 7
 import org.springframework.web.bind.annotation.GetMapping;
9 8
 import org.springframework.web.bind.annotation.PostMapping;
@@ -15,6 +14,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
15 14
 import org.springframework.web.bind.annotation.RestController;
16 15
 import com.ruoyi.common.log.annotation.Log;
17 16
 import com.ruoyi.common.log.enums.BusinessType;
17
+import com.ruoyi.common.security.annotation.PreAuthorize;
18 18
 import ${packageName}.domain.${ClassName};
19 19
 import ${packageName}.service.I${ClassName}Service;
20 20
 import com.ruoyi.common.core.web.controller.BaseController;
@@ -41,7 +41,7 @@ public class ${ClassName}Controller extends BaseController
41 41
     /**
42 42
      * 查询${functionName}列表
43 43
      */
44
-    @PreAuthorize("@ss.hasPermi('${permissionPrefix}:list')")
44
+    @PreAuthorize(hasPermi = "${permissionPrefix}:list")
45 45
     @GetMapping("/list")
46 46
 #if($table.crud)
47 47
     public TableDataInfo list(${ClassName} ${className})
@@ -61,7 +61,7 @@ public class ${ClassName}Controller extends BaseController
61 61
     /**
62 62
      * 导出${functionName}列表
63 63
      */
64
-    @PreAuthorize("@ss.hasPermi('${permissionPrefix}:export')")
64
+    @PreAuthorize(hasPermi = "${permissionPrefix}:export")
65 65
     @Log(title = "${functionName}", businessType = BusinessType.EXPORT)
66 66
     @PostMapping("/export")
67 67
     public void export(HttpServletResponse response, ${ClassName} ${className}) throws IOException
@@ -74,7 +74,7 @@ public class ${ClassName}Controller extends BaseController
74 74
     /**
75 75
      * 获取${functionName}详细信息
76 76
      */
77
-    @PreAuthorize("@ss.hasPermi('${permissionPrefix}:query')")
77
+    @PreAuthorize(hasPermi = "${permissionPrefix}:query")
78 78
     @GetMapping(value = "/{${pkColumn.javaField}}")
79 79
     public AjaxResult getInfo(@PathVariable("${pkColumn.javaField}") ${pkColumn.javaType} ${pkColumn.javaField})
80 80
     {
@@ -84,7 +84,7 @@ public class ${ClassName}Controller extends BaseController
84 84
     /**
85 85
      * 新增${functionName}
86 86
      */
87
-    @PreAuthorize("@ss.hasPermi('${permissionPrefix}:add')")
87
+    @PreAuthorize(hasPermi = "${permissionPrefix}:add")
88 88
     @Log(title = "${functionName}", businessType = BusinessType.INSERT)
89 89
     @PostMapping
90 90
     public AjaxResult add(@RequestBody ${ClassName} ${className})
@@ -95,7 +95,7 @@ public class ${ClassName}Controller extends BaseController
95 95
     /**
96 96
      * 修改${functionName}
97 97
      */
98
-    @PreAuthorize("@ss.hasPermi('${permissionPrefix}:edit')")
98
+    @PreAuthorize(hasPermi = "${permissionPrefix}:edit")
99 99
     @Log(title = "${functionName}", businessType = BusinessType.UPDATE)
100 100
     @PutMapping
101 101
     public AjaxResult edit(@RequestBody ${ClassName} ${className})
@@ -106,7 +106,7 @@ public class ${ClassName}Controller extends BaseController
106 106
     /**
107 107
      * 删除${functionName}
108 108
      */
109
-    @PreAuthorize("@ss.hasPermi('${permissionPrefix}:remove')")
109
+    @PreAuthorize(hasPermi = "${permissionPrefix}:remove")
110 110
     @Log(title = "${functionName}", businessType = BusinessType.DELETE)
111 111
 	@DeleteMapping("/{${pkColumn.javaField}s}")
112 112
     public AjaxResult remove(@PathVariable ${pkColumn.javaType}[] ${pkColumn.javaField}s)

+ 2 - 2
ruoyi-modules/ruoyi-job/pom.xml

@@ -35,10 +35,10 @@
35 35
             <artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
36 36
         </dependency>
37 37
         
38
-        <!-- SpringBoot Web -->
38
+        <!-- SpringBoot Actuator -->
39 39
         <dependency>
40 40
             <groupId>org.springframework.boot</groupId>
41
-            <artifactId>spring-boot-starter-web</artifactId>
41
+            <artifactId>spring-boot-starter-actuator</artifactId>
42 42
         </dependency>
43 43
 		
44 44
         <!-- Swagger -->

+ 9 - 9
ruoyi-modules/ruoyi-job/src/main/java/com/ruoyi/job/controller/SysJobController.java

@@ -5,7 +5,6 @@ import java.util.List;
5 5
 import javax.servlet.http.HttpServletResponse;
6 6
 import org.quartz.SchedulerException;
7 7
 import org.springframework.beans.factory.annotation.Autowired;
8
-import org.springframework.security.access.prepost.PreAuthorize;
9 8
 import org.springframework.web.bind.annotation.DeleteMapping;
10 9
 import org.springframework.web.bind.annotation.GetMapping;
11 10
 import org.springframework.web.bind.annotation.PathVariable;
@@ -21,6 +20,7 @@ import com.ruoyi.common.core.web.domain.AjaxResult;
21 20
 import com.ruoyi.common.core.web.page.TableDataInfo;
22 21
 import com.ruoyi.common.log.annotation.Log;
23 22
 import com.ruoyi.common.log.enums.BusinessType;
23
+import com.ruoyi.common.security.annotation.PreAuthorize;
24 24
 import com.ruoyi.common.security.utils.SecurityUtils;
25 25
 import com.ruoyi.job.domain.SysJob;
26 26
 import com.ruoyi.job.service.ISysJobService;
@@ -41,7 +41,7 @@ public class SysJobController extends BaseController
41 41
     /**
42 42
      * 查询定时任务列表
43 43
      */
44
-    @PreAuthorize("@ss.hasPermi('monitor:job:list')")
44
+    @PreAuthorize(hasPermi = "monitor:job:list")
45 45
     @GetMapping("/list")
46 46
     public TableDataInfo list(SysJob sysJob)
47 47
     {
@@ -53,7 +53,7 @@ public class SysJobController extends BaseController
53 53
     /**
54 54
      * 导出定时任务列表
55 55
      */
56
-    @PreAuthorize("@ss.hasPermi('monitor:job:export')")
56
+    @PreAuthorize(hasPermi = "monitor:job:export")
57 57
     @Log(title = "定时任务", businessType = BusinessType.EXPORT)
58 58
     @PostMapping("/export")
59 59
     public void export(HttpServletResponse response, SysJob sysJob) throws IOException
@@ -66,7 +66,7 @@ public class SysJobController extends BaseController
66 66
     /**
67 67
      * 获取定时任务详细信息
68 68
      */
69
-    @PreAuthorize("@ss.hasPermi('monitor:job:query')")
69
+    @PreAuthorize(hasPermi = "monitor:job:query")
70 70
     @GetMapping(value = "/{jobId}")
71 71
     public AjaxResult getInfo(@PathVariable("jobId") Long jobId)
72 72
     {
@@ -76,7 +76,7 @@ public class SysJobController extends BaseController
76 76
     /**
77 77
      * 新增定时任务
78 78
      */
79
-    @PreAuthorize("@ss.hasPermi('monitor:job:add')")
79
+    @PreAuthorize(hasPermi = "monitor:job:add")
80 80
     @Log(title = "定时任务", businessType = BusinessType.INSERT)
81 81
     @PostMapping
82 82
     public AjaxResult add(@RequestBody SysJob sysJob) throws SchedulerException, TaskException
@@ -92,7 +92,7 @@ public class SysJobController extends BaseController
92 92
     /**
93 93
      * 修改定时任务
94 94
      */
95
-    @PreAuthorize("@ss.hasPermi('monitor:job:edit')")
95
+    @PreAuthorize(hasPermi = "monitor:job:edit")
96 96
     @Log(title = "定时任务", businessType = BusinessType.UPDATE)
97 97
     @PutMapping
98 98
     public AjaxResult edit(@RequestBody SysJob sysJob) throws SchedulerException, TaskException
@@ -108,7 +108,7 @@ public class SysJobController extends BaseController
108 108
     /**
109 109
      * 定时任务状态修改
110 110
      */
111
-    @PreAuthorize("@ss.hasPermi('monitor:job:changeStatus')")
111
+    @PreAuthorize(hasPermi = "monitor:job:changeStatus")
112 112
     @Log(title = "定时任务", businessType = BusinessType.UPDATE)
113 113
     @PutMapping("/changeStatus")
114 114
     public AjaxResult changeStatus(@RequestBody SysJob job) throws SchedulerException
@@ -121,7 +121,7 @@ public class SysJobController extends BaseController
121 121
     /**
122 122
      * 定时任务立即执行一次
123 123
      */
124
-    @PreAuthorize("@ss.hasPermi('monitor:job:changeStatus')")
124
+    @PreAuthorize(hasPermi = "monitor:job:changeStatus")
125 125
     @Log(title = "定时任务", businessType = BusinessType.UPDATE)
126 126
     @PutMapping("/run")
127 127
     public AjaxResult run(@RequestBody SysJob job) throws SchedulerException
@@ -133,7 +133,7 @@ public class SysJobController extends BaseController
133 133
     /**
134 134
      * 删除定时任务
135 135
      */
136
-    @PreAuthorize("@ss.hasPermi('monitor:job:remove')")
136
+    @PreAuthorize(hasPermi = "monitor:job:remove")
137 137
     @Log(title = "定时任务", businessType = BusinessType.DELETE)
138 138
     @DeleteMapping("/{jobIds}")
139 139
     public AjaxResult remove(@PathVariable Long[] jobIds) throws SchedulerException, TaskException

+ 6 - 6
ruoyi-modules/ruoyi-job/src/main/java/com/ruoyi/job/controller/SysJobLogController.java

@@ -4,7 +4,6 @@ import java.io.IOException;
4 4
 import java.util.List;
5 5
 import javax.servlet.http.HttpServletResponse;
6 6
 import org.springframework.beans.factory.annotation.Autowired;
7
-import org.springframework.security.access.prepost.PreAuthorize;
8 7
 import org.springframework.web.bind.annotation.DeleteMapping;
9 8
 import org.springframework.web.bind.annotation.GetMapping;
10 9
 import org.springframework.web.bind.annotation.PathVariable;
@@ -17,6 +16,7 @@ import com.ruoyi.common.core.web.domain.AjaxResult;
17 16
 import com.ruoyi.common.core.web.page.TableDataInfo;
18 17
 import com.ruoyi.common.log.annotation.Log;
19 18
 import com.ruoyi.common.log.enums.BusinessType;
19
+import com.ruoyi.common.security.annotation.PreAuthorize;
20 20
 import com.ruoyi.job.domain.SysJobLog;
21 21
 import com.ruoyi.job.service.ISysJobLogService;
22 22
 
@@ -35,7 +35,7 @@ public class SysJobLogController extends BaseController
35 35
     /**
36 36
      * 查询定时任务调度日志列表
37 37
      */
38
-    @PreAuthorize("@ss.hasPermi('monitor:job:list')")
38
+    @PreAuthorize(hasPermi = "monitor:job:list")
39 39
     @GetMapping("/list")
40 40
     public TableDataInfo list(SysJobLog sysJobLog)
41 41
     {
@@ -47,7 +47,7 @@ public class SysJobLogController extends BaseController
47 47
     /**
48 48
      * 导出定时任务调度日志列表
49 49
      */
50
-    @PreAuthorize("@ss.hasPermi('monitor:job:export')")
50
+    @PreAuthorize(hasPermi = "monitor:job:export")
51 51
     @Log(title = "任务调度日志", businessType = BusinessType.EXPORT)
52 52
     @PostMapping("/export")
53 53
     public void export(HttpServletResponse response, SysJobLog sysJobLog) throws IOException
@@ -60,7 +60,7 @@ public class SysJobLogController extends BaseController
60 60
     /**
61 61
      * 根据调度编号获取详细信息
62 62
      */
63
-    @PreAuthorize("@ss.hasPermi('monitor:job:query')")
63
+    @PreAuthorize(hasPermi = "monitor:job:query")
64 64
     @GetMapping(value = "/{configId}")
65 65
     public AjaxResult getInfo(@PathVariable Long jobLogId)
66 66
     {
@@ -70,7 +70,7 @@ public class SysJobLogController extends BaseController
70 70
     /**
71 71
      * 删除定时任务调度日志
72 72
      */
73
-    @PreAuthorize("@ss.hasPermi('monitor:job:remove')")
73
+    @PreAuthorize(hasPermi = "monitor:job:remove")
74 74
     @Log(title = "定时任务调度日志", businessType = BusinessType.DELETE)
75 75
     @DeleteMapping("/{jobLogIds}")
76 76
     public AjaxResult remove(@PathVariable Long[] jobLogIds)
@@ -81,7 +81,7 @@ public class SysJobLogController extends BaseController
81 81
     /**
82 82
      * 清空定时任务调度日志
83 83
      */
84
-    @PreAuthorize("@ss.hasPermi('monitor:job:remove')")
84
+    @PreAuthorize(hasPermi = "monitor:job:remove")
85 85
     @Log(title = "调度日志", businessType = BusinessType.CLEAN)
86 86
     @DeleteMapping("/clean")
87 87
     public AjaxResult clean()

+ 2 - 2
ruoyi-modules/ruoyi-system/pom.xml

@@ -35,10 +35,10 @@
35 35
             <artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
36 36
         </dependency>
37 37
         
38
-    	<!-- SpringBoot Web -->
38
+    	<!-- SpringBoot Actuator -->
39 39
         <dependency>
40 40
             <groupId>org.springframework.boot</groupId>
41
-            <artifactId>spring-boot-starter-web</artifactId>
41
+            <artifactId>spring-boot-starter-actuator</artifactId>
42 42
         </dependency>
43 43
 		
44 44
         <!-- Swagger -->

+ 0 - 94
ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysClientDetailsController.java

@@ -1,94 +0,0 @@
1
-package com.ruoyi.system.controller;
2
-
3
-import java.util.List;
4
-import org.springframework.beans.factory.annotation.Autowired;
5
-import org.springframework.security.access.prepost.PreAuthorize;
6
-import org.springframework.web.bind.annotation.DeleteMapping;
7
-import org.springframework.web.bind.annotation.GetMapping;
8
-import org.springframework.web.bind.annotation.PathVariable;
9
-import org.springframework.web.bind.annotation.PostMapping;
10
-import org.springframework.web.bind.annotation.PutMapping;
11
-import org.springframework.web.bind.annotation.RequestBody;
12
-import org.springframework.web.bind.annotation.RequestMapping;
13
-import org.springframework.web.bind.annotation.RestController;
14
-import com.ruoyi.common.core.utils.StringUtils;
15
-import com.ruoyi.common.core.web.controller.BaseController;
16
-import com.ruoyi.common.core.web.domain.AjaxResult;
17
-import com.ruoyi.common.core.web.page.TableDataInfo;
18
-import com.ruoyi.common.log.annotation.Log;
19
-import com.ruoyi.common.log.enums.BusinessType;
20
-import com.ruoyi.system.domain.SysClientDetails;
21
-import com.ruoyi.system.service.ISysClientDetailsService;
22
-
23
-/**
24
- * 终端配置 信息操作处理
25
- * 
26
- * @author ruoyi
27
- */
28
-@RestController
29
-@RequestMapping("/client")
30
-public class SysClientDetailsController extends BaseController
31
-{
32
-    @Autowired
33
-    private ISysClientDetailsService sysClientDetailsService;
34
-
35
-    /**
36
-     * 查询终端配置列表
37
-     */
38
-    @PreAuthorize("@ss.hasPermi('system:client:list')")
39
-    @GetMapping("/list")
40
-    public TableDataInfo list(SysClientDetails sysClientDetails)
41
-    {
42
-        startPage();
43
-        List<SysClientDetails> list = sysClientDetailsService.selectSysClientDetailsList(sysClientDetails);
44
-        return getDataTable(list);
45
-    }
46
-
47
-    /**
48
-     * 获取终端配置详细信息
49
-     */
50
-    @PreAuthorize("@ss.hasPermi('system:client:query')")
51
-    @GetMapping(value = "/{clientId}")
52
-    public AjaxResult getInfo(@PathVariable("clientId") String clientId)
53
-    {
54
-        return AjaxResult.success(sysClientDetailsService.selectSysClientDetailsById(clientId));
55
-    }
56
-
57
-    /**
58
-     * 新增终端配置
59
-     */
60
-    @PreAuthorize("@ss.hasPermi('system:client:add')")
61
-    @Log(title = "终端配置", businessType = BusinessType.INSERT)
62
-    @PostMapping
63
-    public AjaxResult add(@RequestBody SysClientDetails sysClientDetails)
64
-    {
65
-        String clientId = sysClientDetails.getClientId();
66
-        if (StringUtils.isNotNull(sysClientDetailsService.selectSysClientDetailsById(clientId)))
67
-        {
68
-            return AjaxResult.error("新增终端'" + clientId + "'失败,编号已存在");
69
-        }
70
-        return toAjax(sysClientDetailsService.insertSysClientDetails(sysClientDetails));
71
-    }
72
-
73
-    /**
74
-     * 修改终端配置
75
-     */
76
-    @PreAuthorize("@ss.hasPermi('system:client:edit')")
77
-    @Log(title = "终端配置", businessType = BusinessType.UPDATE)
78
-    @PutMapping
79
-    public AjaxResult edit(@RequestBody SysClientDetails sysClientDetails)
80
-    {
81
-        return toAjax(sysClientDetailsService.updateSysClientDetails(sysClientDetails));
82
-    }
83
-
84
-    /**
85
-     * 删除终端配置
86
-     */
87
-    @PreAuthorize("@ss.hasPermi('system:client:remove')")
88
-    @Log(title = "终端配置", businessType = BusinessType.DELETE)
89
-    @DeleteMapping("/{clientIds}")
90
-    public AjaxResult remove(@PathVariable String[] clientIds)
91
-    {
92
-        return toAjax(sysClientDetailsService.deleteSysClientDetailsByIds(clientIds));
93
-    }
94
-}

+ 7 - 7
ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysConfigController.java

@@ -4,7 +4,6 @@ import java.io.IOException;
4 4
 import java.util.List;
5 5
 import javax.servlet.http.HttpServletResponse;
6 6
 import org.springframework.beans.factory.annotation.Autowired;
7
-import org.springframework.security.access.prepost.PreAuthorize;
8 7
 import org.springframework.validation.annotation.Validated;
9 8
 import org.springframework.web.bind.annotation.DeleteMapping;
10 9
 import org.springframework.web.bind.annotation.GetMapping;
@@ -21,6 +20,7 @@ import com.ruoyi.common.core.web.domain.AjaxResult;
21 20
 import com.ruoyi.common.core.web.page.TableDataInfo;
22 21
 import com.ruoyi.common.log.annotation.Log;
23 22
 import com.ruoyi.common.log.enums.BusinessType;
23
+import com.ruoyi.common.security.annotation.PreAuthorize;
24 24
 import com.ruoyi.common.security.utils.SecurityUtils;
25 25
 import com.ruoyi.system.domain.SysConfig;
26 26
 import com.ruoyi.system.service.ISysConfigService;
@@ -40,7 +40,7 @@ public class SysConfigController extends BaseController
40 40
     /**
41 41
      * 获取参数配置列表
42 42
      */
43
-    @PreAuthorize("@ss.hasPermi('system:config:list')")
43
+    @PreAuthorize(hasPermi = "system:config:list")
44 44
     @GetMapping("/list")
45 45
     public TableDataInfo list(SysConfig config)
46 46
     {
@@ -50,7 +50,7 @@ public class SysConfigController extends BaseController
50 50
     }
51 51
 
52 52
     @Log(title = "参数管理", businessType = BusinessType.EXPORT)
53
-    @PreAuthorize("@ss.hasPermi('system:config:export')")
53
+    @PreAuthorize(hasPermi = "system:config:export")
54 54
     @PostMapping("/export")
55 55
     public void export(HttpServletResponse response, SysConfig config) throws IOException
56 56
     {
@@ -80,7 +80,7 @@ public class SysConfigController extends BaseController
80 80
     /**
81 81
      * 新增参数配置
82 82
      */
83
-    @PreAuthorize("@ss.hasPermi('system:config:add')")
83
+    @PreAuthorize(hasPermi = "system:config:add")
84 84
     @Log(title = "参数管理", businessType = BusinessType.INSERT)
85 85
     @PostMapping
86 86
     public AjaxResult add(@Validated @RequestBody SysConfig config)
@@ -96,7 +96,7 @@ public class SysConfigController extends BaseController
96 96
     /**
97 97
      * 修改参数配置
98 98
      */
99
-    @PreAuthorize("@ss.hasPermi('system:config:edit')")
99
+    @PreAuthorize(hasPermi = "system:config:edit")
100 100
     @Log(title = "参数管理", businessType = BusinessType.UPDATE)
101 101
     @PutMapping
102 102
     public AjaxResult edit(@Validated @RequestBody SysConfig config)
@@ -112,7 +112,7 @@ public class SysConfigController extends BaseController
112 112
     /**
113 113
      * 删除参数配置
114 114
      */
115
-    @PreAuthorize("@ss.hasPermi('system:config:remove')")
115
+    @PreAuthorize(hasPermi = "system:config:remove")
116 116
     @Log(title = "参数管理", businessType = BusinessType.DELETE)
117 117
     @DeleteMapping("/{configIds}")
118 118
     public AjaxResult remove(@PathVariable Long[] configIds)
@@ -123,7 +123,7 @@ public class SysConfigController extends BaseController
123 123
     /**
124 124
      * 清空缓存
125 125
      */
126
-    @PreAuthorize("@ss.hasPermi('system:config:remove')")
126
+    @PreAuthorize(hasPermi = "system:config:remove")
127 127
     @Log(title = "参数管理", businessType = BusinessType.CLEAN)
128 128
     @DeleteMapping("/clearCache")
129 129
     public AjaxResult clearCache()

+ 7 - 9
ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysDeptController.java

@@ -2,10 +2,8 @@ package com.ruoyi.system.controller;
2 2
 
3 3
 import java.util.Iterator;
4 4
 import java.util.List;
5
-
6 5
 import org.apache.commons.lang3.ArrayUtils;
7 6
 import org.springframework.beans.factory.annotation.Autowired;
8
-import org.springframework.security.access.prepost.PreAuthorize;
9 7
 import org.springframework.validation.annotation.Validated;
10 8
 import org.springframework.web.bind.annotation.DeleteMapping;
11 9
 import org.springframework.web.bind.annotation.GetMapping;
@@ -15,13 +13,13 @@ import org.springframework.web.bind.annotation.PutMapping;
15 13
 import org.springframework.web.bind.annotation.RequestBody;
16 14
 import org.springframework.web.bind.annotation.RequestMapping;
17 15
 import org.springframework.web.bind.annotation.RestController;
18
-
19 16
 import com.ruoyi.common.core.constant.UserConstants;
20 17
 import com.ruoyi.common.core.utils.StringUtils;
21 18
 import com.ruoyi.common.core.web.controller.BaseController;
22 19
 import com.ruoyi.common.core.web.domain.AjaxResult;
23 20
 import com.ruoyi.common.log.annotation.Log;
24 21
 import com.ruoyi.common.log.enums.BusinessType;
22
+import com.ruoyi.common.security.annotation.PreAuthorize;
25 23
 import com.ruoyi.common.security.utils.SecurityUtils;
26 24
 import com.ruoyi.system.api.domain.SysDept;
27 25
 import com.ruoyi.system.service.ISysDeptService;
@@ -41,7 +39,7 @@ public class SysDeptController extends BaseController
41 39
     /**
42 40
      * 获取部门列表
43 41
      */
44
-    @PreAuthorize("@ss.hasPermi('system:dept:list')")
42
+    @PreAuthorize(hasPermi = "system:dept:list")
45 43
     @GetMapping("/list")
46 44
     public AjaxResult list(SysDept dept)
47 45
     {
@@ -52,7 +50,7 @@ public class SysDeptController extends BaseController
52 50
     /**
53 51
      * 查询部门列表(排除节点)
54 52
      */
55
-    @PreAuthorize("@ss.hasPermi('system:dept:list')")
53
+    @PreAuthorize(hasPermi = "system:dept:list")
56 54
     @GetMapping("/list/exclude/{deptId}")
57 55
     public AjaxResult excludeChild(@PathVariable(value = "deptId", required = false) Long deptId)
58 56
     {
@@ -73,7 +71,7 @@ public class SysDeptController extends BaseController
73 71
     /**
74 72
      * 根据部门编号获取详细信息
75 73
      */
76
-    @PreAuthorize("@ss.hasPermi('system:dept:query')")
74
+    @PreAuthorize(hasPermi = "system:dept:query")
77 75
     @GetMapping(value = "/{deptId}")
78 76
     public AjaxResult getInfo(@PathVariable Long deptId)
79 77
     {
@@ -106,7 +104,7 @@ public class SysDeptController extends BaseController
106 104
     /**
107 105
      * 新增部门
108 106
      */
109
-    @PreAuthorize("@ss.hasPermi('system:dept:add')")
107
+    @PreAuthorize(hasPermi = "system:dept:add")
110 108
     @Log(title = "部门管理", businessType = BusinessType.INSERT)
111 109
     @PostMapping
112 110
     public AjaxResult add(@Validated @RequestBody SysDept dept)
@@ -122,7 +120,7 @@ public class SysDeptController extends BaseController
122 120
     /**
123 121
      * 修改部门
124 122
      */
125
-    @PreAuthorize("@ss.hasPermi('system:dept:edit')")
123
+    @PreAuthorize(hasPermi = "system:dept:edit")
126 124
     @Log(title = "部门管理", businessType = BusinessType.UPDATE)
127 125
     @PutMapping
128 126
     public AjaxResult edit(@Validated @RequestBody SysDept dept)
@@ -147,7 +145,7 @@ public class SysDeptController extends BaseController
147 145
     /**
148 146
      * 删除部门
149 147
      */
150
-    @PreAuthorize("@ss.hasPermi('system:dept:remove')")
148
+    @PreAuthorize(hasPermi = "system:dept:remove")
151 149
     @Log(title = "部门管理", businessType = BusinessType.DELETE)
152 150
     @DeleteMapping("/{deptId}")
153 151
     public AjaxResult remove(@PathVariable Long deptId)

+ 7 - 7
ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysDictDataController.java

@@ -4,7 +4,6 @@ import java.io.IOException;
4 4
 import java.util.List;
5 5
 import javax.servlet.http.HttpServletResponse;
6 6
 import org.springframework.beans.factory.annotation.Autowired;
7
-import org.springframework.security.access.prepost.PreAuthorize;
8 7
 import org.springframework.validation.annotation.Validated;
9 8
 import org.springframework.web.bind.annotation.DeleteMapping;
10 9
 import org.springframework.web.bind.annotation.GetMapping;
@@ -20,6 +19,7 @@ import com.ruoyi.common.core.web.domain.AjaxResult;
20 19
 import com.ruoyi.common.core.web.page.TableDataInfo;
21 20
 import com.ruoyi.common.log.annotation.Log;
22 21
 import com.ruoyi.common.log.enums.BusinessType;
22
+import com.ruoyi.common.security.annotation.PreAuthorize;
23 23
 import com.ruoyi.common.security.utils.SecurityUtils;
24 24
 import com.ruoyi.system.domain.SysDictData;
25 25
 import com.ruoyi.system.service.ISysDictDataService;
@@ -40,7 +40,7 @@ public class SysDictDataController extends BaseController
40 40
     @Autowired
41 41
     private ISysDictTypeService dictTypeService;
42 42
 
43
-    @PreAuthorize("@ss.hasPermi('system:dict:list')")
43
+    @PreAuthorize(hasPermi = "system:dict:list")
44 44
     @GetMapping("/list")
45 45
     public TableDataInfo list(SysDictData dictData)
46 46
     {
@@ -50,7 +50,7 @@ public class SysDictDataController extends BaseController
50 50
     }
51 51
 
52 52
     @Log(title = "字典数据", businessType = BusinessType.EXPORT)
53
-    @PreAuthorize("@ss.hasPermi('system:dict:export')")
53
+    @PreAuthorize(hasPermi = "system:dict:export")
54 54
     @PostMapping("/export")
55 55
     public void export(HttpServletResponse response, SysDictData dictData) throws IOException
56 56
     {
@@ -62,7 +62,7 @@ public class SysDictDataController extends BaseController
62 62
     /**
63 63
      * 查询字典数据详细
64 64
      */
65
-    @PreAuthorize("@ss.hasPermi('system:dict:query')")
65
+    @PreAuthorize(hasPermi = "system:dict:query")
66 66
     @GetMapping(value = "/{dictCode}")
67 67
     public AjaxResult getInfo(@PathVariable Long dictCode)
68 68
     {
@@ -81,7 +81,7 @@ public class SysDictDataController extends BaseController
81 81
     /**
82 82
      * 新增字典类型
83 83
      */
84
-    @PreAuthorize("@ss.hasPermi('system:dict:add')")
84
+    @PreAuthorize(hasPermi = "system:dict:add")
85 85
     @Log(title = "字典数据", businessType = BusinessType.INSERT)
86 86
     @PostMapping
87 87
     public AjaxResult add(@Validated @RequestBody SysDictData dict)
@@ -93,7 +93,7 @@ public class SysDictDataController extends BaseController
93 93
     /**
94 94
      * 修改保存字典类型
95 95
      */
96
-    @PreAuthorize("@ss.hasPermi('system:dict:edit')")
96
+    @PreAuthorize(hasPermi = "system:dict:edit")
97 97
     @Log(title = "字典数据", businessType = BusinessType.UPDATE)
98 98
     @PutMapping
99 99
     public AjaxResult edit(@Validated @RequestBody SysDictData dict)
@@ -105,7 +105,7 @@ public class SysDictDataController extends BaseController
105 105
     /**
106 106
      * 删除字典类型
107 107
      */
108
-    @PreAuthorize("@ss.hasPermi('system:dict:remove')")
108
+    @PreAuthorize(hasPermi = "system:dict:remove")
109 109
     @Log(title = "字典类型", businessType = BusinessType.DELETE)
110 110
     @DeleteMapping("/{dictCodes}")
111 111
     public AjaxResult remove(@PathVariable Long[] dictCodes)

+ 8 - 8
ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysDictTypeController.java

@@ -4,7 +4,6 @@ import java.io.IOException;
4 4
 import java.util.List;
5 5
 import javax.servlet.http.HttpServletResponse;
6 6
 import org.springframework.beans.factory.annotation.Autowired;
7
-import org.springframework.security.access.prepost.PreAuthorize;
8 7
 import org.springframework.validation.annotation.Validated;
9 8
 import org.springframework.web.bind.annotation.DeleteMapping;
10 9
 import org.springframework.web.bind.annotation.GetMapping;
@@ -21,6 +20,7 @@ import com.ruoyi.common.core.web.domain.AjaxResult;
21 20
 import com.ruoyi.common.core.web.page.TableDataInfo;
22 21
 import com.ruoyi.common.log.annotation.Log;
23 22
 import com.ruoyi.common.log.enums.BusinessType;
23
+import com.ruoyi.common.security.annotation.PreAuthorize;
24 24
 import com.ruoyi.common.security.utils.SecurityUtils;
25 25
 import com.ruoyi.system.domain.SysDictType;
26 26
 import com.ruoyi.system.service.ISysDictTypeService;
@@ -37,7 +37,7 @@ public class SysDictTypeController extends BaseController
37 37
     @Autowired
38 38
     private ISysDictTypeService dictTypeService;
39 39
 
40
-    @PreAuthorize("@ss.hasPermi('system:dict:list')")
40
+    @PreAuthorize(hasPermi = "system:dict:list")
41 41
     @GetMapping("/list")
42 42
     public TableDataInfo list(SysDictType dictType)
43 43
     {
@@ -47,7 +47,7 @@ public class SysDictTypeController extends BaseController
47 47
     }
48 48
 
49 49
     @Log(title = "字典类型", businessType = BusinessType.EXPORT)
50
-    @PreAuthorize("@ss.hasPermi('system:dict:export')")
50
+    @PreAuthorize(hasPermi = "system:dict:export")
51 51
     @PostMapping("/export")
52 52
     public void export(HttpServletResponse response, SysDictType dictType) throws IOException
53 53
     {
@@ -59,7 +59,7 @@ public class SysDictTypeController extends BaseController
59 59
     /**
60 60
      * 查询字典类型详细
61 61
      */
62
-    @PreAuthorize("@ss.hasPermi('system:dict:query')")
62
+    @PreAuthorize(hasPermi = "system:dict:query")
63 63
     @GetMapping(value = "/{dictId}")
64 64
     public AjaxResult getInfo(@PathVariable Long dictId)
65 65
     {
@@ -69,7 +69,7 @@ public class SysDictTypeController extends BaseController
69 69
     /**
70 70
      * 新增字典类型
71 71
      */
72
-    @PreAuthorize("@ss.hasPermi('system:dict:add')")
72
+    @PreAuthorize(hasPermi = "system:dict:add")
73 73
     @Log(title = "字典类型", businessType = BusinessType.INSERT)
74 74
     @PostMapping
75 75
     public AjaxResult add(@Validated @RequestBody SysDictType dict)
@@ -85,7 +85,7 @@ public class SysDictTypeController extends BaseController
85 85
     /**
86 86
      * 修改字典类型
87 87
      */
88
-    @PreAuthorize("@ss.hasPermi('system:dict:edit')")
88
+    @PreAuthorize(hasPermi = "system:dict:edit")
89 89
     @Log(title = "字典类型", businessType = BusinessType.UPDATE)
90 90
     @PutMapping
91 91
     public AjaxResult edit(@Validated @RequestBody SysDictType dict)
@@ -101,7 +101,7 @@ public class SysDictTypeController extends BaseController
101 101
     /**
102 102
      * 删除字典类型
103 103
      */
104
-    @PreAuthorize("@ss.hasPermi('system:dict:remove')")
104
+    @PreAuthorize(hasPermi = "system:dict:remove")
105 105
     @Log(title = "字典类型", businessType = BusinessType.DELETE)
106 106
     @DeleteMapping("/{dictIds}")
107 107
     public AjaxResult remove(@PathVariable Long[] dictIds)
@@ -112,7 +112,7 @@ public class SysDictTypeController extends BaseController
112 112
     /**
113 113
      * 清空缓存
114 114
      */
115
-    @PreAuthorize("@ss.hasPermi('system:dict:remove')")
115
+    @PreAuthorize(hasPermi = "system:dict:remove")
116 116
     @Log(title = "字典类型", businessType = BusinessType.CLEAN)
117 117
     @DeleteMapping("/clearCache")
118 118
     public AjaxResult clearCache()

+ 5 - 5
ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysLogininforController.java

@@ -4,7 +4,6 @@ import java.io.IOException;
4 4
 import java.util.List;
5 5
 import javax.servlet.http.HttpServletResponse;
6 6
 import org.springframework.beans.factory.annotation.Autowired;
7
-import org.springframework.security.access.prepost.PreAuthorize;
8 7
 import org.springframework.web.bind.annotation.DeleteMapping;
9 8
 import org.springframework.web.bind.annotation.GetMapping;
10 9
 import org.springframework.web.bind.annotation.PathVariable;
@@ -21,6 +20,7 @@ import com.ruoyi.common.core.web.domain.AjaxResult;
21 20
 import com.ruoyi.common.core.web.page.TableDataInfo;
22 21
 import com.ruoyi.common.log.annotation.Log;
23 22
 import com.ruoyi.common.log.enums.BusinessType;
23
+import com.ruoyi.common.security.annotation.PreAuthorize;
24 24
 import com.ruoyi.system.domain.SysLogininfor;
25 25
 import com.ruoyi.system.service.ISysLogininforService;
26 26
 
@@ -36,7 +36,7 @@ public class SysLogininforController extends BaseController
36 36
     @Autowired
37 37
     private ISysLogininforService logininforService;
38 38
 
39
-    @PreAuthorize("@ss.hasPermi('system:logininfor:list')")
39
+    @PreAuthorize(hasPermi = "system:logininfor:list")
40 40
     @GetMapping("/list")
41 41
     public TableDataInfo list(SysLogininfor logininfor)
42 42
     {
@@ -46,7 +46,7 @@ public class SysLogininforController extends BaseController
46 46
     }
47 47
 
48 48
     @Log(title = "登陆日志", businessType = BusinessType.EXPORT)
49
-    @PreAuthorize("@ss.hasPermi('system:logininfor:export')")
49
+    @PreAuthorize(hasPermi = "system:logininfor:export")
50 50
     @PostMapping("/export")
51 51
     public void export(HttpServletResponse response, SysLogininfor logininfor) throws IOException
52 52
     {
@@ -55,7 +55,7 @@ public class SysLogininforController extends BaseController
55 55
         util.exportExcel(response, list, "登陆日志");
56 56
     }
57 57
 
58
-    @PreAuthorize("@ss.hasPermi('system:logininfor:remove')")
58
+    @PreAuthorize(hasPermi = "system:logininfor:remove")
59 59
     @Log(title = "登陆日志", businessType = BusinessType.DELETE)
60 60
     @DeleteMapping("/{infoIds}")
61 61
     public AjaxResult remove(@PathVariable Long[] infoIds)
@@ -63,7 +63,7 @@ public class SysLogininforController extends BaseController
63 63
         return toAjax(logininforService.deleteLogininforByIds(infoIds));
64 64
     }
65 65
 
66
-    @PreAuthorize("@ss.hasPermi('system:logininfor:remove')")
66
+    @PreAuthorize(hasPermi = "system:logininfor:remove")
67 67
     @Log(title = "登陆日志", businessType = BusinessType.DELETE)
68 68
     @DeleteMapping("/clean")
69 69
     public AjaxResult clean()

+ 10 - 14
ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysMenuController.java

@@ -2,7 +2,6 @@ package com.ruoyi.system.controller;
2 2
 
3 3
 import java.util.List;
4 4
 import org.springframework.beans.factory.annotation.Autowired;
5
-import org.springframework.security.access.prepost.PreAuthorize;
6 5
 import org.springframework.validation.annotation.Validated;
7 6
 import org.springframework.web.bind.annotation.DeleteMapping;
8 7
 import org.springframework.web.bind.annotation.GetMapping;
@@ -19,7 +18,7 @@ import com.ruoyi.common.core.web.controller.BaseController;
19 18
 import com.ruoyi.common.core.web.domain.AjaxResult;
20 19
 import com.ruoyi.common.log.annotation.Log;
21 20
 import com.ruoyi.common.log.enums.BusinessType;
22
-import com.ruoyi.common.security.domain.LoginUser;
21
+import com.ruoyi.common.security.annotation.PreAuthorize;
23 22
 import com.ruoyi.common.security.utils.SecurityUtils;
24 23
 import com.ruoyi.system.domain.SysMenu;
25 24
 import com.ruoyi.system.service.ISysMenuService;
@@ -39,12 +38,11 @@ public class SysMenuController extends BaseController
39 38
     /**
40 39
      * 获取菜单列表
41 40
      */
42
-    @PreAuthorize("@ss.hasPermi('system:menu:list')")
41
+    @PreAuthorize(hasPermi = "system:menu:list")
43 42
     @GetMapping("/list")
44 43
     public AjaxResult list(SysMenu menu)
45 44
     {
46
-        LoginUser loginUser = SecurityUtils.getLoginUser();
47
-        Long userId = loginUser.getUserId();
45
+        Long userId = SecurityUtils.getUserId();
48 46
         List<SysMenu> menus = menuService.selectMenuList(menu, userId);
49 47
         return AjaxResult.success(menus);
50 48
     }
@@ -52,7 +50,7 @@ public class SysMenuController extends BaseController
52 50
     /**
53 51
      * 根据菜单编号获取详细信息
54 52
      */
55
-    @PreAuthorize("@ss.hasPermi('system:menu:query')")
53
+    @PreAuthorize(hasPermi = "system:menu:query")
56 54
     @GetMapping(value = "/{menuId}")
57 55
     public AjaxResult getInfo(@PathVariable Long menuId)
58 56
     {
@@ -65,8 +63,7 @@ public class SysMenuController extends BaseController
65 63
     @GetMapping("/treeselect")
66 64
     public AjaxResult treeselect(SysMenu menu)
67 65
     {
68
-        LoginUser loginUser = SecurityUtils.getLoginUser();
69
-        Long userId = loginUser.getUserId();
66
+        Long userId = SecurityUtils.getUserId();
70 67
         List<SysMenu> menus = menuService.selectMenuList(menu, userId);
71 68
         return AjaxResult.success(menuService.buildMenuTreeSelect(menus));
72 69
     }
@@ -77,8 +74,7 @@ public class SysMenuController extends BaseController
77 74
     @GetMapping(value = "/roleMenuTreeselect/{roleId}")
78 75
     public AjaxResult roleMenuTreeselect(@PathVariable("roleId") Long roleId)
79 76
     {
80
-        LoginUser loginUser = SecurityUtils.getLoginUser();
81
-        Long userId = loginUser.getUserId();
77
+        Long userId = SecurityUtils.getUserId();
82 78
         List<SysMenu> menus = menuService.selectMenuList(userId);
83 79
         AjaxResult ajax = AjaxResult.success();
84 80
         ajax.put("checkedKeys", menuService.selectMenuListByRoleId(roleId));
@@ -89,7 +85,7 @@ public class SysMenuController extends BaseController
89 85
     /**
90 86
      * 新增菜单
91 87
      */
92
-    @PreAuthorize("@ss.hasPermi('system:menu:add')")
88
+    @PreAuthorize(hasPermi = "system:menu:add")
93 89
     @Log(title = "菜单管理", businessType = BusinessType.INSERT)
94 90
     @PostMapping
95 91
     public AjaxResult add(@Validated @RequestBody SysMenu menu)
@@ -110,7 +106,7 @@ public class SysMenuController extends BaseController
110 106
     /**
111 107
      * 修改菜单
112 108
      */
113
-    @PreAuthorize("@ss.hasPermi('system:menu:edit')")
109
+    @PreAuthorize(hasPermi = "system:menu:edit")
114 110
     @Log(title = "菜单管理", businessType = BusinessType.UPDATE)
115 111
     @PutMapping
116 112
     public AjaxResult edit(@Validated @RequestBody SysMenu menu)
@@ -135,7 +131,7 @@ public class SysMenuController extends BaseController
135 131
     /**
136 132
      * 删除菜单
137 133
      */
138
-    @PreAuthorize("@ss.hasPermi('system:menu:remove')")
134
+    @PreAuthorize(hasPermi = "system:menu:remove")
139 135
     @Log(title = "菜单管理", businessType = BusinessType.DELETE)
140 136
     @DeleteMapping("/{menuId}")
141 137
     public AjaxResult remove(@PathVariable("menuId") Long menuId)
@@ -159,7 +155,7 @@ public class SysMenuController extends BaseController
159 155
     @GetMapping("getRouters")
160 156
     public AjaxResult getRouters()
161 157
     {
162
-        Long userId = SecurityUtils.getLoginUser().getUserId();
158
+        Long userId = SecurityUtils.getUserId();
163 159
         List<SysMenu> menus = menuService.selectMenuTreeByUserId(userId);
164 160
         return AjaxResult.success(menuService.buildMenus(menus));
165 161
     }

+ 6 - 6
ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysNoticeController.java

@@ -2,7 +2,6 @@ package com.ruoyi.system.controller;
2 2
 
3 3
 import java.util.List;
4 4
 import org.springframework.beans.factory.annotation.Autowired;
5
-import org.springframework.security.access.prepost.PreAuthorize;
6 5
 import org.springframework.validation.annotation.Validated;
7 6
 import org.springframework.web.bind.annotation.DeleteMapping;
8 7
 import org.springframework.web.bind.annotation.GetMapping;
@@ -17,6 +16,7 @@ import com.ruoyi.common.core.web.domain.AjaxResult;
17 16
 import com.ruoyi.common.core.web.page.TableDataInfo;
18 17
 import com.ruoyi.common.log.annotation.Log;
19 18
 import com.ruoyi.common.log.enums.BusinessType;
19
+import com.ruoyi.common.security.annotation.PreAuthorize;
20 20
 import com.ruoyi.common.security.utils.SecurityUtils;
21 21
 import com.ruoyi.system.domain.SysNotice;
22 22
 import com.ruoyi.system.service.ISysNoticeService;
@@ -36,7 +36,7 @@ public class SysNoticeController extends BaseController
36 36
     /**
37 37
      * 获取通知公告列表
38 38
      */
39
-    @PreAuthorize("@ss.hasPermi('system:notice:list')")
39
+    @PreAuthorize(hasPermi = "system:notice:list")
40 40
     @GetMapping("/list")
41 41
     public TableDataInfo list(SysNotice notice)
42 42
     {
@@ -48,7 +48,7 @@ public class SysNoticeController extends BaseController
48 48
     /**
49 49
      * 根据通知公告编号获取详细信息
50 50
      */
51
-    @PreAuthorize("@ss.hasPermi('system:notice:query')")
51
+    @PreAuthorize(hasPermi = "system:notice:query")
52 52
     @GetMapping(value = "/{noticeId}")
53 53
     public AjaxResult getInfo(@PathVariable Long noticeId)
54 54
     {
@@ -58,7 +58,7 @@ public class SysNoticeController extends BaseController
58 58
     /**
59 59
      * 新增通知公告
60 60
      */
61
-    @PreAuthorize("@ss.hasPermi('system:notice:add')")
61
+    @PreAuthorize(hasPermi = "system:notice:add")
62 62
     @Log(title = "通知公告", businessType = BusinessType.UPDATE)
63 63
     @PostMapping
64 64
     public AjaxResult add(@Validated @RequestBody SysNotice notice)
@@ -70,7 +70,7 @@ public class SysNoticeController extends BaseController
70 70
     /**
71 71
      * 修改通知公告
72 72
      */
73
-    @PreAuthorize("@ss.hasPermi('system:notice:edit')")
73
+    @PreAuthorize(hasPermi = "system:notice:edit")
74 74
     @Log(title = "通知公告", businessType = BusinessType.UPDATE)
75 75
     @PutMapping
76 76
     public AjaxResult edit(@Validated @RequestBody SysNotice notice)
@@ -82,7 +82,7 @@ public class SysNoticeController extends BaseController
82 82
     /**
83 83
      * 删除通知公告
84 84
      */
85
-    @PreAuthorize("@ss.hasPermi('system:notice:remove')")
85
+    @PreAuthorize(hasPermi = "system:notice:remove")
86 86
     @Log(title = "通知公告", businessType = BusinessType.DELETE)
87 87
     @DeleteMapping("/{noticeIds}")
88 88
     public AjaxResult remove(@PathVariable Long[] noticeIds)

+ 5 - 5
ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysOperlogController.java

@@ -4,7 +4,6 @@ import java.io.IOException;
4 4
 import java.util.List;
5 5
 import javax.servlet.http.HttpServletResponse;
6 6
 import org.springframework.beans.factory.annotation.Autowired;
7
-import org.springframework.security.access.prepost.PreAuthorize;
8 7
 import org.springframework.web.bind.annotation.DeleteMapping;
9 8
 import org.springframework.web.bind.annotation.GetMapping;
10 9
 import org.springframework.web.bind.annotation.PathVariable;
@@ -18,6 +17,7 @@ import com.ruoyi.common.core.web.domain.AjaxResult;
18 17
 import com.ruoyi.common.core.web.page.TableDataInfo;
19 18
 import com.ruoyi.common.log.annotation.Log;
20 19
 import com.ruoyi.common.log.enums.BusinessType;
20
+import com.ruoyi.common.security.annotation.PreAuthorize;
21 21
 import com.ruoyi.system.api.domain.SysOperLog;
22 22
 import com.ruoyi.system.service.ISysOperLogService;
23 23
 
@@ -33,7 +33,7 @@ public class SysOperlogController extends BaseController
33 33
     @Autowired
34 34
     private ISysOperLogService operLogService;
35 35
 
36
-    @PreAuthorize("@ss.hasPermi('system:operlog:list')")
36
+    @PreAuthorize(hasPermi = "system:operlog:list")
37 37
     @GetMapping("/list")
38 38
     public TableDataInfo list(SysOperLog operLog)
39 39
     {
@@ -43,7 +43,7 @@ public class SysOperlogController extends BaseController
43 43
     }
44 44
 
45 45
     @Log(title = "操作日志", businessType = BusinessType.EXPORT)
46
-    @PreAuthorize("@ss.hasPermi('system:operlog:export')")
46
+    @PreAuthorize(hasPermi = "system:operlog:export")
47 47
     @PostMapping("/export")
48 48
     public void export(HttpServletResponse response, SysOperLog operLog) throws IOException
49 49
     {
@@ -52,14 +52,14 @@ public class SysOperlogController extends BaseController
52 52
         util.exportExcel(response, list, "操作日志");
53 53
     }
54 54
 
55
-    @PreAuthorize("@ss.hasPermi('system:operlog:remove')")
55
+    @PreAuthorize(hasPermi = "system:operlog:remove")
56 56
     @DeleteMapping("/{operIds}")
57 57
     public AjaxResult remove(@PathVariable Long[] operIds)
58 58
     {
59 59
         return toAjax(operLogService.deleteOperLogByIds(operIds));
60 60
     }
61 61
 
62
-    @PreAuthorize("@ss.hasPermi('system:operlog:remove')")
62
+    @PreAuthorize(hasPermi = "system:operlog:remove")
63 63
     @Log(title = "操作日志", businessType = BusinessType.CLEAN)
64 64
     @DeleteMapping("/clean")
65 65
     public AjaxResult clean()

+ 7 - 7
ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysPostController.java

@@ -4,7 +4,6 @@ import java.io.IOException;
4 4
 import java.util.List;
5 5
 import javax.servlet.http.HttpServletResponse;
6 6
 import org.springframework.beans.factory.annotation.Autowired;
7
-import org.springframework.security.access.prepost.PreAuthorize;
8 7
 import org.springframework.validation.annotation.Validated;
9 8
 import org.springframework.web.bind.annotation.DeleteMapping;
10 9
 import org.springframework.web.bind.annotation.GetMapping;
@@ -21,6 +20,7 @@ import com.ruoyi.common.core.web.domain.AjaxResult;
21 20
 import com.ruoyi.common.core.web.page.TableDataInfo;
22 21
 import com.ruoyi.common.log.annotation.Log;
23 22
 import com.ruoyi.common.log.enums.BusinessType;
23
+import com.ruoyi.common.security.annotation.PreAuthorize;
24 24
 import com.ruoyi.common.security.utils.SecurityUtils;
25 25
 import com.ruoyi.system.domain.SysPost;
26 26
 import com.ruoyi.system.service.ISysPostService;
@@ -40,7 +40,7 @@ public class SysPostController extends BaseController
40 40
     /**
41 41
      * 获取岗位列表
42 42
      */
43
-    @PreAuthorize("@ss.hasPermi('system:post:list')")
43
+    @PreAuthorize(hasPermi = "system:post:list")
44 44
     @GetMapping("/list")
45 45
     public TableDataInfo list(SysPost post)
46 46
     {
@@ -50,7 +50,7 @@ public class SysPostController extends BaseController
50 50
     }
51 51
 
52 52
     @Log(title = "岗位管理", businessType = BusinessType.EXPORT)
53
-    @PreAuthorize("@ss.hasPermi('system:post:export')")
53
+    @PreAuthorize(hasPermi = "system:post:export")
54 54
     @PostMapping("/export")
55 55
     public void export(HttpServletResponse response, SysPost post) throws IOException
56 56
     {
@@ -62,7 +62,7 @@ public class SysPostController extends BaseController
62 62
     /**
63 63
      * 根据岗位编号获取详细信息
64 64
      */
65
-    @PreAuthorize("@ss.hasPermi('system:post:query')")
65
+    @PreAuthorize(hasPermi = "system:post:query")
66 66
     @GetMapping(value = "/{postId}")
67 67
     public AjaxResult getInfo(@PathVariable Long postId)
68 68
     {
@@ -72,7 +72,7 @@ public class SysPostController extends BaseController
72 72
     /**
73 73
      * 新增岗位
74 74
      */
75
-    @PreAuthorize("@ss.hasPermi('system:post:add')")
75
+    @PreAuthorize(hasPermi = "system:post:add")
76 76
     @Log(title = "岗位管理", businessType = BusinessType.INSERT)
77 77
     @PostMapping
78 78
     public AjaxResult add(@Validated @RequestBody SysPost post)
@@ -92,7 +92,7 @@ public class SysPostController extends BaseController
92 92
     /**
93 93
      * 修改岗位
94 94
      */
95
-    @PreAuthorize("@ss.hasPermi('system:post:edit')")
95
+    @PreAuthorize(hasPermi = "system:post:edit")
96 96
     @Log(title = "岗位管理", businessType = BusinessType.UPDATE)
97 97
     @PutMapping
98 98
     public AjaxResult edit(@Validated @RequestBody SysPost post)
@@ -112,7 +112,7 @@ public class SysPostController extends BaseController
112 112
     /**
113 113
      * 删除岗位
114 114
      */
115
-    @PreAuthorize("@ss.hasPermi('system:post:remove')")
115
+    @PreAuthorize(hasPermi = "system:post:remove")
116 116
     @Log(title = "岗位管理", businessType = BusinessType.DELETE)
117 117
     @DeleteMapping("/{postIds}")
118 118
     public AjaxResult remove(@PathVariable Long[] postIds)

+ 10 - 10
ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysRoleController.java

@@ -4,7 +4,6 @@ import java.io.IOException;
4 4
 import java.util.List;
5 5
 import javax.servlet.http.HttpServletResponse;
6 6
 import org.springframework.beans.factory.annotation.Autowired;
7
-import org.springframework.security.access.prepost.PreAuthorize;
8 7
 import org.springframework.validation.annotation.Validated;
9 8
 import org.springframework.web.bind.annotation.DeleteMapping;
10 9
 import org.springframework.web.bind.annotation.GetMapping;
@@ -21,6 +20,7 @@ import com.ruoyi.common.core.web.domain.AjaxResult;
21 20
 import com.ruoyi.common.core.web.page.TableDataInfo;
22 21
 import com.ruoyi.common.log.annotation.Log;
23 22
 import com.ruoyi.common.log.enums.BusinessType;
23
+import com.ruoyi.common.security.annotation.PreAuthorize;
24 24
 import com.ruoyi.common.security.utils.SecurityUtils;
25 25
 import com.ruoyi.system.api.domain.SysRole;
26 26
 import com.ruoyi.system.service.ISysRoleService;
@@ -37,7 +37,7 @@ public class SysRoleController extends BaseController
37 37
     @Autowired
38 38
     private ISysRoleService roleService;
39 39
 
40
-    @PreAuthorize("@ss.hasPermi('system:role:list')")
40
+    @PreAuthorize(hasPermi = "system:role:list")
41 41
     @GetMapping("/list")
42 42
     public TableDataInfo list(SysRole role)
43 43
     {
@@ -47,7 +47,7 @@ public class SysRoleController extends BaseController
47 47
     }
48 48
 
49 49
     @Log(title = "角色管理", businessType = BusinessType.EXPORT)
50
-    @PreAuthorize("@ss.hasPermi('system:role:export')")
50
+    @PreAuthorize(hasPermi = "system:role:export")
51 51
     @PostMapping("/export")
52 52
     public void export(HttpServletResponse response, SysRole role) throws IOException
53 53
     {
@@ -59,7 +59,7 @@ public class SysRoleController extends BaseController
59 59
     /**
60 60
      * 根据角色编号获取详细信息
61 61
      */
62
-    @PreAuthorize("@ss.hasPermi('system:role:query')")
62
+    @PreAuthorize(hasPermi = "system:role:query")
63 63
     @GetMapping(value = "/{roleId}")
64 64
     public AjaxResult getInfo(@PathVariable Long roleId)
65 65
     {
@@ -69,7 +69,7 @@ public class SysRoleController extends BaseController
69 69
     /**
70 70
      * 新增角色
71 71
      */
72
-    @PreAuthorize("@ss.hasPermi('system:role:add')")
72
+    @PreAuthorize(hasPermi = "system:role:add")
73 73
     @Log(title = "角色管理", businessType = BusinessType.INSERT)
74 74
     @PostMapping
75 75
     public AjaxResult add(@Validated @RequestBody SysRole role)
@@ -90,7 +90,7 @@ public class SysRoleController extends BaseController
90 90
     /**
91 91
      * 修改保存角色
92 92
      */
93
-    @PreAuthorize("@ss.hasPermi('system:role:edit')")
93
+    @PreAuthorize(hasPermi = "system:role:edit")
94 94
     @Log(title = "角色管理", businessType = BusinessType.UPDATE)
95 95
     @PutMapping
96 96
     public AjaxResult edit(@Validated @RequestBody SysRole role)
@@ -111,7 +111,7 @@ public class SysRoleController extends BaseController
111 111
     /**
112 112
      * 修改保存数据权限
113 113
      */
114
-    @PreAuthorize("@ss.hasPermi('system:role:edit')")
114
+    @PreAuthorize(hasPermi = "system:role:edit")
115 115
     @Log(title = "角色管理", businessType = BusinessType.UPDATE)
116 116
     @PutMapping("/dataScope")
117 117
     public AjaxResult dataScope(@RequestBody SysRole role)
@@ -123,7 +123,7 @@ public class SysRoleController extends BaseController
123 123
     /**
124 124
      * 状态修改
125 125
      */
126
-    @PreAuthorize("@ss.hasPermi('system:role:edit')")
126
+    @PreAuthorize(hasPermi = "system:role:edit")
127 127
     @Log(title = "角色管理", businessType = BusinessType.UPDATE)
128 128
     @PutMapping("/changeStatus")
129 129
     public AjaxResult changeStatus(@RequestBody SysRole role)
@@ -136,7 +136,7 @@ public class SysRoleController extends BaseController
136 136
     /**
137 137
      * 删除角色
138 138
      */
139
-    @PreAuthorize("@ss.hasPermi('system:role:remove')")
139
+    @PreAuthorize(hasPermi = "system:role:remove")
140 140
     @Log(title = "角色管理", businessType = BusinessType.DELETE)
141 141
     @DeleteMapping("/{roleIds}")
142 142
     public AjaxResult remove(@PathVariable Long[] roleIds)
@@ -147,7 +147,7 @@ public class SysRoleController extends BaseController
147 147
     /**
148 148
      * 获取角色选择框列表
149 149
      */
150
-    @PreAuthorize("@ss.hasPermi('system:role:query')")
150
+    @PreAuthorize(hasPermi = "system:role:query")
151 151
     @GetMapping("/optionselect")
152 152
     public AjaxResult optionselect()
153 153
     {

+ 14 - 14
ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysUserController.java

@@ -6,7 +6,6 @@ import java.util.Set;
6 6
 import java.util.stream.Collectors;
7 7
 import javax.servlet.http.HttpServletResponse;
8 8
 import org.springframework.beans.factory.annotation.Autowired;
9
-import org.springframework.security.access.prepost.PreAuthorize;
10 9
 import org.springframework.validation.annotation.Validated;
11 10
 import org.springframework.web.bind.annotation.DeleteMapping;
12 11
 import org.springframework.web.bind.annotation.GetMapping;
@@ -26,10 +25,11 @@ import com.ruoyi.common.core.web.domain.AjaxResult;
26 25
 import com.ruoyi.common.core.web.page.TableDataInfo;
27 26
 import com.ruoyi.common.log.annotation.Log;
28 27
 import com.ruoyi.common.log.enums.BusinessType;
28
+import com.ruoyi.common.security.annotation.PreAuthorize;
29 29
 import com.ruoyi.common.security.utils.SecurityUtils;
30 30
 import com.ruoyi.system.api.domain.SysRole;
31 31
 import com.ruoyi.system.api.domain.SysUser;
32
-import com.ruoyi.system.api.model.UserInfo;
32
+import com.ruoyi.system.api.model.LoginUser;
33 33
 import com.ruoyi.system.service.ISysPermissionService;
34 34
 import com.ruoyi.system.service.ISysPostService;
35 35
 import com.ruoyi.system.service.ISysRoleService;
@@ -59,7 +59,7 @@ public class SysUserController extends BaseController
59 59
     /**
60 60
      * 获取用户列表
61 61
      */
62
-    @PreAuthorize("@ss.hasPermi('system:user:list')")
62
+    @PreAuthorize(hasPermi = "system:user:list")
63 63
     @GetMapping("/list")
64 64
     public TableDataInfo list(SysUser user)
65 65
     {
@@ -69,7 +69,7 @@ public class SysUserController extends BaseController
69 69
     }
70 70
 
71 71
     @Log(title = "用户管理", businessType = BusinessType.EXPORT)
72
-    @PreAuthorize("@ss.hasPermi('system:user:export')")
72
+    @PreAuthorize(hasPermi = "system:user:export")
73 73
     @PostMapping("/export")
74 74
     public void export(HttpServletResponse response, SysUser user) throws IOException
75 75
     {
@@ -79,7 +79,7 @@ public class SysUserController extends BaseController
79 79
     }
80 80
 
81 81
     @Log(title = "用户管理", businessType = BusinessType.IMPORT)
82
-    @PreAuthorize("@ss.hasPermi('system:user:import')")
82
+    @PreAuthorize(hasPermi = "system:user:import")
83 83
     @PostMapping("/importData")
84 84
     public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception
85 85
     {
@@ -101,7 +101,7 @@ public class SysUserController extends BaseController
101 101
      * 获取当前用户信息
102 102
      */
103 103
     @GetMapping("/info/{username}")
104
-    public R<UserInfo> info(@PathVariable("username") String username)
104
+    public R<LoginUser> info(@PathVariable("username") String username)
105 105
     {
106 106
         SysUser sysUser = userService.selectUserByUserName(username);
107 107
         if (StringUtils.isNull(sysUser))
@@ -112,7 +112,7 @@ public class SysUserController extends BaseController
112 112
         Set<String> roles = permissionService.getRolePermission(sysUser.getUserId());
113 113
         // 权限集合
114 114
         Set<String> permissions = permissionService.getMenuPermission(sysUser.getUserId());
115
-        UserInfo sysUserVo = new UserInfo();
115
+        LoginUser sysUserVo = new LoginUser();
116 116
         sysUserVo.setSysUser(sysUser);
117 117
         sysUserVo.setRoles(roles);
118 118
         sysUserVo.setPermissions(permissions);
@@ -127,7 +127,7 @@ public class SysUserController extends BaseController
127 127
     @GetMapping("getInfo")
128 128
     public AjaxResult getInfo()
129 129
     {
130
-        Long userId = SecurityUtils.getLoginUser().getUserId();
130
+        Long userId = SecurityUtils.getUserId();
131 131
         // 角色集合
132 132
         Set<String> roles = permissionService.getRolePermission(userId);
133 133
         // 权限集合
@@ -142,7 +142,7 @@ public class SysUserController extends BaseController
142 142
     /**
143 143
      * 根据用户编号获取详细信息
144 144
      */
145
-    @PreAuthorize("@ss.hasPermi('system:user:query')")
145
+    @PreAuthorize(hasPermi = "system:user:query")
146 146
     @GetMapping(value = { "/", "/{userId}" })
147 147
     public AjaxResult getInfo(@PathVariable(value = "userId", required = false) Long userId)
148 148
     {
@@ -162,7 +162,7 @@ public class SysUserController extends BaseController
162 162
     /**
163 163
      * 新增用户
164 164
      */
165
-    @PreAuthorize("@ss.hasPermi('system:user:add')")
165
+    @PreAuthorize(hasPermi = "system:user:add")
166 166
     @Log(title = "用户管理", businessType = BusinessType.INSERT)
167 167
     @PostMapping
168 168
     public AjaxResult add(@Validated @RequestBody SysUser user)
@@ -187,7 +187,7 @@ public class SysUserController extends BaseController
187 187
     /**
188 188
      * 修改用户
189 189
      */
190
-    @PreAuthorize("@ss.hasPermi('system:user:edit')")
190
+    @PreAuthorize(hasPermi = "system:user:edit")
191 191
     @Log(title = "用户管理", businessType = BusinessType.UPDATE)
192 192
     @PutMapping
193 193
     public AjaxResult edit(@Validated @RequestBody SysUser user)
@@ -208,7 +208,7 @@ public class SysUserController extends BaseController
208 208
     /**
209 209
      * 删除用户
210 210
      */
211
-    @PreAuthorize("@ss.hasPermi('system:user:remove')")
211
+    @PreAuthorize(hasPermi = "system:user:remove")
212 212
     @Log(title = "用户管理", businessType = BusinessType.DELETE)
213 213
     @DeleteMapping("/{userIds}")
214 214
     public AjaxResult remove(@PathVariable Long[] userIds)
@@ -219,7 +219,7 @@ public class SysUserController extends BaseController
219 219
     /**
220 220
      * 重置密码
221 221
      */
222
-    @PreAuthorize("@ss.hasPermi('system:user:edit')")
222
+    @PreAuthorize(hasPermi = "system:user:edit")
223 223
     @Log(title = "用户管理", businessType = BusinessType.UPDATE)
224 224
     @PutMapping("/resetPwd")
225 225
     public AjaxResult resetPwd(@RequestBody SysUser user)
@@ -233,7 +233,7 @@ public class SysUserController extends BaseController
233 233
     /**
234 234
      * 状态修改
235 235
      */
236
-    @PreAuthorize("@ss.hasPermi('system:user:edit')")
236
+    @PreAuthorize(hasPermi = "system:user:edit")
237 237
     @Log(title = "用户管理", businessType = BusinessType.UPDATE)
238 238
     @PutMapping("/changeStatus")
239 239
     public AjaxResult changeStatus(@RequestBody SysUser user)

+ 0 - 213
ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysClientDetails.java

@@ -1,213 +0,0 @@
1
-package com.ruoyi.system.domain;
2
-
3
-import org.apache.commons.lang3.builder.ToStringBuilder;
4
-import org.apache.commons.lang3.builder.ToStringStyle;
5
-import com.ruoyi.common.core.web.domain.BaseEntity;
6
-
7
-/**
8
- * 终端配置表 sys_oauth_client_details
9
- *
10
- * @author ruoyi
11
- */
12
-public class SysClientDetails extends BaseEntity
13
-{
14
-    private static final long serialVersionUID = 1L;
15
-
16
-    /**
17
-     * 终端编号
18
-     */
19
-    private String clientId;
20
-
21
-    /**
22
-     * 资源ID标识
23
-     */
24
-    private String resourceIds;
25
-
26
-    /**
27
-     * 终端安全码
28
-     */
29
-    private String clientSecret;
30
-
31
-    /**
32
-     * 终端授权范围
33
-     */
34
-    private String scope;
35
-
36
-    /**
37
-     * 终端授权类型
38
-     */
39
-    private String authorizedGrantTypes;
40
-
41
-    /**
42
-     * 服务器回调地址
43
-     */
44
-    private String webServerRedirectUri;
45
-
46
-    /**
47
-     * 访问资源所需权限
48
-     */
49
-    private String authorities;
50
-
51
-    /**
52
-     * 设定终端的access_token的有效时间值(秒)
53
-     */
54
-    private Integer accessTokenValidity;
55
-
56
-    /**
57
-     * 设定终端的refresh_token的有效时间值(秒)
58
-     */
59
-    private Integer refreshTokenValidity;
60
-
61
-    /**
62
-     * 附加信息
63
-     */
64
-    private String additionalInformation;
65
-
66
-    /**
67
-     * 是否登录时跳过授权
68
-     */
69
-    private String autoapprove;
70
-
71
-    /**
72
-     * 终端明文安全码
73
-     */
74
-    private String originSecret;
75
-
76
-    public String getClientId()
77
-    {
78
-        return clientId;
79
-    }
80
-
81
-    public void setClientId(String clientId)
82
-    {
83
-        this.clientId = clientId;
84
-    }
85
-
86
-    public String getResourceIds()
87
-    {
88
-        return resourceIds;
89
-    }
90
-
91
-    public void setResourceIds(String resourceIds)
92
-    {
93
-        this.resourceIds = resourceIds;
94
-    }
95
-
96
-    public String getClientSecret()
97
-    {
98
-        return clientSecret;
99
-    }
100
-
101
-    public void setClientSecret(String clientSecret)
102
-    {
103
-        this.clientSecret = clientSecret;
104
-    }
105
-
106
-    public String getScope()
107
-    {
108
-        return scope;
109
-    }
110
-
111
-    public void setScope(String scope)
112
-    {
113
-        this.scope = scope;
114
-    }
115
-
116
-    public String getAuthorizedGrantTypes()
117
-    {
118
-        return authorizedGrantTypes;
119
-    }
120
-
121
-    public void setAuthorizedGrantTypes(String authorizedGrantTypes)
122
-    {
123
-        this.authorizedGrantTypes = authorizedGrantTypes;
124
-    }
125
-
126
-    public String getWebServerRedirectUri()
127
-    {
128
-        return webServerRedirectUri;
129
-    }
130
-
131
-    public void setWebServerRedirectUri(String webServerRedirectUri)
132
-    {
133
-        this.webServerRedirectUri = webServerRedirectUri;
134
-    }
135
-
136
-    public String getAuthorities()
137
-    {
138
-        return authorities;
139
-    }
140
-
141
-    public void setAuthorities(String authorities)
142
-    {
143
-        this.authorities = authorities;
144
-    }
145
-
146
-    public Integer getAccessTokenValidity()
147
-    {
148
-        return accessTokenValidity;
149
-    }
150
-
151
-    public void setAccessTokenValidity(Integer accessTokenValidity)
152
-    {
153
-        this.accessTokenValidity = accessTokenValidity;
154
-    }
155
-
156
-    public Integer getRefreshTokenValidity()
157
-    {
158
-        return refreshTokenValidity;
159
-    }
160
-
161
-    public void setRefreshTokenValidity(Integer refreshTokenValidity)
162
-    {
163
-        this.refreshTokenValidity = refreshTokenValidity;
164
-    }
165
-
166
-    public String getAdditionalInformation()
167
-    {
168
-        return additionalInformation;
169
-    }
170
-
171
-    public void setAdditionalInformation(String additionalInformation)
172
-    {
173
-        this.additionalInformation = additionalInformation;
174
-    }
175
-
176
-    public String getAutoapprove()
177
-    {
178
-        return autoapprove;
179
-    }
180
-
181
-    public void setAutoapprove(String autoapprove)
182
-    {
183
-        this.autoapprove = autoapprove;
184
-    }
185
-
186
-    public String getOriginSecret()
187
-    {
188
-        return originSecret;
189
-    }
190
-
191
-    public void setOriginSecret(String originSecret)
192
-    {
193
-        this.originSecret = originSecret;
194
-    }
195
-
196
-    @Override
197
-    public String toString() {
198
-        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
199
-            .append("clientId", getClientId())
200
-            .append("resourceIds", getResourceIds())
201
-            .append("clientSecret", getClientSecret())
202
-            .append("scope", getScope())
203
-            .append("authorizedGrantTypes", getAuthorizedGrantTypes())
204
-            .append("webServerRedirectUri", getWebServerRedirectUri())
205
-            .append("authorities", getAuthorities())
206
-            .append("accessTokenValidity", getAccessTokenValidity())
207
-            .append("refreshTokenValidity", getRefreshTokenValidity())
208
-            .append("additionalInformation", getAdditionalInformation())
209
-            .append("autoapprove", getAutoapprove())
210
-            .append("originSecret", getOriginSecret())
211
-            .toString();
212
-    }
213
-}

+ 0 - 60
ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysClientDetailsMapper.java

@@ -1,60 +0,0 @@
1
-package com.ruoyi.system.mapper;
2
-
3
-import java.util.List;
4
-import com.ruoyi.system.domain.SysClientDetails;
5
-
6
-/**
7
- * 终端配置Mapper接口
8
- * 
9
- * @author ruoyi
10
- */
11
-public interface SysClientDetailsMapper
12
-{
13
-    /**
14
-     * 查询终端配置
15
-     * 
16
-     * @param clientId 终端配置ID
17
-     * @return 终端配置
18
-     */
19
-    public SysClientDetails selectSysClientDetailsById(String clientId);
20
-
21
-    /**
22
-     * 查询终端配置列表
23
-     * 
24
-     * @param sysClientDetails 终端配置
25
-     * @return 终端配置集合
26
-     */
27
-    public List<SysClientDetails> selectSysClientDetailsList(SysClientDetails sysClientDetails);
28
-
29
-    /**
30
-     * 新增终端配置
31
-     * 
32
-     * @param sysClientDetails 终端配置
33
-     * @return 结果
34
-     */
35
-    public int insertSysClientDetails(SysClientDetails sysClientDetails);
36
-
37
-    /**
38
-     * 修改终端配置
39
-     * 
40
-     * @param sysClientDetails 终端配置
41
-     * @return 结果
42
-     */
43
-    public int updateSysClientDetails(SysClientDetails sysClientDetails);
44
-
45
-    /**
46
-     * 删除终端配置
47
-     * 
48
-     * @param clientId 终端配置ID
49
-     * @return 结果
50
-     */
51
-    public int deleteSysClientDetailsById(String clientId);
52
-
53
-    /**
54
-     * 批量删除终端配置
55
-     * 
56
-     * @param clientIds 需要删除的数据ID
57
-     * @return 结果
58
-     */
59
-    public int deleteSysClientDetailsByIds(String[] clientIds);
60
-}

+ 0 - 52
ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysClientDetailsService.java

@@ -1,52 +0,0 @@
1
-package com.ruoyi.system.service;
2
-
3
-import java.util.List;
4
-import com.ruoyi.system.domain.SysClientDetails;
5
-
6
-/**
7
- * 终端配置Service接口
8
- * 
9
- * @author ruoyi
10
- */
11
-public interface ISysClientDetailsService
12
-{
13
-    /**
14
-     * 查询终端配置
15
-     * 
16
-     * @param clientId 终端配置ID
17
-     * @return 终端配置
18
-     */
19
-    public SysClientDetails selectSysClientDetailsById(String clientId);
20
-
21
-    /**
22
-     * 查询终端配置列表
23
-     * 
24
-     * @param sysClientDetails 终端配置
25
-     * @return 终端配置集合
26
-     */
27
-    public List<SysClientDetails> selectSysClientDetailsList(SysClientDetails sysClientDetails);
28
-
29
-    /**
30
-     * 新增终端配置
31
-     * 
32
-     * @param sysClientDetails 终端配置
33
-     * @return 结果
34
-     */
35
-    public int insertSysClientDetails(SysClientDetails sysClientDetails);
36
-
37
-    /**
38
-     * 修改终端配置
39
-     * 
40
-     * @param sysClientDetails 终端配置
41
-     * @return 结果
42
-     */
43
-    public int updateSysClientDetails(SysClientDetails sysClientDetails);
44
-
45
-    /**
46
-     * 批量删除终端配置
47
-     * 
48
-     * @param clientIds 需要删除的终端配置ID
49
-     * @return 结果
50
-     */
51
-    public int deleteSysClientDetailsByIds(String[] clientIds);
52
-}

+ 0 - 87
ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysClientDetailsServiceImpl.java

@@ -1,87 +0,0 @@
1
-package com.ruoyi.system.service.impl;
2
-
3
-import java.util.List;
4
-import org.springframework.beans.factory.annotation.Autowired;
5
-import org.springframework.cache.annotation.CacheEvict;
6
-import org.springframework.stereotype.Service;
7
-import com.ruoyi.common.core.constant.CacheConstants;
8
-import com.ruoyi.common.security.utils.SecurityUtils;
9
-import com.ruoyi.system.domain.SysClientDetails;
10
-import com.ruoyi.system.mapper.SysClientDetailsMapper;
11
-import com.ruoyi.system.service.ISysClientDetailsService;
12
-
13
-/**
14
- * 终端配置Service业务层处理
15
- * 
16
- * @author ruoyi
17
- */
18
-@Service
19
-public class SysClientDetailsServiceImpl implements ISysClientDetailsService
20
-{
21
-    @Autowired
22
-    private SysClientDetailsMapper sysClientDetailsMapper;
23
-
24
-    /**
25
-     * 查询终端配置
26
-     * 
27
-     * @param clientId 终端配置ID
28
-     * @return 终端配置
29
-     */
30
-    @Override
31
-    public SysClientDetails selectSysClientDetailsById(String clientId)
32
-    {
33
-        return sysClientDetailsMapper.selectSysClientDetailsById(clientId);
34
-    }
35
-
36
-    /**
37
-     * 查询终端配置列表
38
-     * 
39
-     * @param sysClientDetails 终端配置
40
-     * @return 终端配置
41
-     */
42
-    @Override
43
-    public List<SysClientDetails> selectSysClientDetailsList(SysClientDetails sysClientDetails)
44
-    {
45
-        return sysClientDetailsMapper.selectSysClientDetailsList(sysClientDetails);
46
-    }
47
-
48
-    /**
49
-     * 新增终端配置
50
-     * 
51
-     * @param sysClientDetails 终端配置
52
-     * @return 结果
53
-     */
54
-    @Override
55
-    public int insertSysClientDetails(SysClientDetails sysClientDetails)
56
-    {
57
-        sysClientDetails.setClientSecret(SecurityUtils.encryptPassword(sysClientDetails.getOriginSecret()));
58
-        return sysClientDetailsMapper.insertSysClientDetails(sysClientDetails);
59
-    }
60
-
61
-    /**
62
-     * 修改终端配置
63
-     * 
64
-     * @param sysClientDetails 终端配置
65
-     * @return 结果
66
-     */
67
-    @Override
68
-    @CacheEvict(value = CacheConstants.CLIENT_DETAILS_KEY, key = "#sysClientDetails.clientId")
69
-    public int updateSysClientDetails(SysClientDetails sysClientDetails)
70
-    {
71
-        sysClientDetails.setClientSecret(SecurityUtils.encryptPassword(sysClientDetails.getOriginSecret()));
72
-        return sysClientDetailsMapper.updateSysClientDetails(sysClientDetails);
73
-    }
74
-
75
-    /**
76
-     * 批量删除终端配置
77
-     * 
78
-     * @param clientIds 需要删除的终端配置ID
79
-     * @return 结果
80
-     */
81
-    @Override
82
-    @CacheEvict(value = CacheConstants.CLIENT_DETAILS_KEY, allEntries = true)
83
-    public int deleteSysClientDetailsByIds(String[] clientIds)
84
-    {
85
-        return sysClientDetailsMapper.deleteSysClientDetailsByIds(clientIds);
86
-    }
87
-}

+ 0 - 99
ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SysClientDetailsMapper.xml

@@ -1,99 +0,0 @@
1
-<?xml version="1.0" encoding="UTF-8" ?>
2
-<!DOCTYPE mapper
3
-PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
4
-"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
5
-<mapper namespace="com.ruoyi.system.mapper.SysClientDetailsMapper">
6
-    
7
-    <resultMap type="SysClientDetails" id="SysClientDetailsResult">
8
-        <result property="clientId"               column="client_id"                />
9
-        <result property="resourceIds"            column="resource_ids"             />
10
-        <result property="clientSecret"           column="client_secret"            />
11
-        <result property="scope"                  column="scope"                    />
12
-        <result property="authorizedGrantTypes"   column="authorized_grant_types"   />
13
-        <result property="webServerRedirectUri"   column="web_server_redirect_uri"  />
14
-        <result property="authorities"            column="authorities"              />
15
-        <result property="accessTokenValidity"    column="access_token_validity"    />
16
-        <result property="refreshTokenValidity"   column="refresh_token_validity"   />
17
-        <result property="additionalInformation"  column="additional_information"   />
18
-        <result property="autoapprove"            column="autoapprove"              />
19
-        <result property="originSecret"           column="origin_secret"            />
20
-    </resultMap>
21
-
22
-    <sql id="selectSysClientDetailsVo">
23
-        select client_id, resource_ids, client_secret, scope, authorized_grant_types, web_server_redirect_uri, authorities, access_token_validity, refresh_token_validity, additional_information, autoapprove, origin_secret from sys_oauth_client_details
24
-    </sql>
25
-
26
-    <select id="selectSysClientDetailsList" parameterType="SysClientDetails" resultMap="SysClientDetailsResult">
27
-        <include refid="selectSysClientDetailsVo"/>
28
-        <where>  
29
-            <if test="clientId != null  and clientId != ''"> and client_id = #{clientId}</if>
30
-        </where>
31
-    </select>
32
-    
33
-    <select id="selectSysClientDetailsById" parameterType="String" resultMap="SysClientDetailsResult">
34
-        <include refid="selectSysClientDetailsVo"/>
35
-        where client_id = #{clientId}
36
-    </select>
37
-        
38
-    <insert id="insertSysClientDetails" parameterType="SysClientDetails">
39
-        insert into sys_oauth_client_details
40
-        <trim prefix="(" suffix=")" suffixOverrides=",">
41
-            <if test="clientId != null">client_id,</if>
42
-            <if test="resourceIds != null">resource_ids,</if>
43
-            <if test="clientSecret != null">client_secret,</if>
44
-            <if test="scope != null">scope,</if>
45
-            <if test="authorizedGrantTypes != null">authorized_grant_types,</if>
46
-            <if test="webServerRedirectUri != null">web_server_redirect_uri,</if>
47
-            <if test="authorities != null">authorities,</if>
48
-            <if test="accessTokenValidity != null">access_token_validity,</if>
49
-            <if test="refreshTokenValidity != null">refresh_token_validity,</if>
50
-            <if test="additionalInformation != null">additional_information,</if>
51
-            <if test="autoapprove != null">autoapprove,</if>
52
-            <if test="originSecret != null">origin_secret,</if>
53
-         </trim>
54
-        <trim prefix="values (" suffix=")" suffixOverrides=",">
55
-            <if test="clientId != null">#{clientId},</if>
56
-            <if test="resourceIds != null">#{resourceIds},</if>
57
-            <if test="clientSecret != null">#{clientSecret},</if>
58
-            <if test="scope != null">#{scope},</if>
59
-            <if test="authorizedGrantTypes != null">#{authorizedGrantTypes},</if>
60
-            <if test="webServerRedirectUri != null">#{webServerRedirectUri},</if>
61
-            <if test="authorities != null">#{authorities},</if>
62
-            <if test="accessTokenValidity != null">#{accessTokenValidity},</if>
63
-            <if test="refreshTokenValidity != null">#{refreshTokenValidity},</if>
64
-            <if test="additionalInformation != null">#{additionalInformation},</if>
65
-            <if test="autoapprove != null ">#{autoapprove},</if>
66
-            <if test="originSecret != null ">#{originSecret},</if>
67
-         </trim>
68
-    </insert>
69
-
70
-    <update id="updateSysClientDetails" parameterType="SysClientDetails">
71
-        update sys_oauth_client_details
72
-        <trim prefix="SET" suffixOverrides=",">
73
-            <if test="resourceIds != null">resource_ids = #{resourceIds},</if>
74
-            <if test="clientSecret != null">client_secret = #{clientSecret},</if>
75
-            <if test="scope != null">scope = #{scope},</if>
76
-            <if test="authorizedGrantTypes != null">authorized_grant_types = #{authorizedGrantTypes},</if>
77
-            <if test="webServerRedirectUri != null">web_server_redirect_uri = #{webServerRedirectUri},</if>
78
-            <if test="authorities != null">authorities = #{authorities},</if>
79
-            <if test="accessTokenValidity != null">access_token_validity = #{accessTokenValidity},</if>
80
-            <if test="refreshTokenValidity != null">refresh_token_validity = #{refreshTokenValidity},</if>
81
-            <if test="additionalInformation != null">additional_information = #{additionalInformation},</if>
82
-            <if test="autoapprove != null">autoapprove = #{autoapprove},</if>
83
-            <if test="originSecret != null">origin_secret = #{originSecret},</if>
84
-        </trim>
85
-        where client_id = #{clientId}
86
-    </update>
87
-
88
-    <delete id="deleteSysClientDetailsById" parameterType="String">
89
-        delete from sys_oauth_client_details where client_id = #{clientId}
90
-    </delete>
91
-
92
-    <delete id="deleteSysClientDetailsByIds" parameterType="String">
93
-        delete from sys_oauth_client_details where client_id in 
94
-        <foreach item="clientId" collection="array" open="(" separator="," close=")">
95
-            #{clientId}
96
-        </foreach>
97
-    </delete>
98
-    
99
-</mapper>

+ 6 - 9
ruoyi-ui/src/api/login.js

@@ -6,21 +6,18 @@ const scope = 'server'
6 6
 
7 7
 // 登录方法
8 8
 export function login(username, password, code, uuid) {
9
-  const grant_type = 'password'
10 9
   return request({
11
-    url: '/auth/oauth/token',
10
+    url: '/auth/login',
12 11
     method: 'post',
13
-    params: { username, password, code, uuid, client_id, client_secret, grant_type, scope }
12
+    data: { username, password, code, uuid }
14 13
   })
15 14
 }
16 15
 
17 16
 // 刷新方法
18
-export function refreshToken(refresh_token) {
19
-  const grant_type = 'refresh_token'
17
+export function refreshToken() {
20 18
   return request({
21
-    url: '/auth/oauth/token',
22
-    method: 'post',
23
-    params: { client_id, client_secret, grant_type, scope, refresh_token }
19
+    url: '/auth/refresh',
20
+    method: 'post'
24 21
   })
25 22
 }
26 23
 
@@ -35,7 +32,7 @@ export function getInfo() {
35 32
 // 退出方法
36 33
 export function logout() {
37 34
   return request({
38
-    url: '/auth/token/logout',
35
+    url: '/auth/logout',
39 36
     method: 'delete'
40 37
   })
41 38
 }

+ 0 - 44
ruoyi-ui/src/api/system/client.js

@@ -1,44 +0,0 @@
1
-import request from '@/utils/request'
2
-
3
-// 查询终端配置列表
4
-export function listClient(query) {
5
-  return request({
6
-    url: '/system/client/list',
7
-    method: 'get',
8
-    params: query
9
-  })
10
-}
11
-
12
-// 查询终端配置详细
13
-export function getClient(clientId) {
14
-  return request({
15
-    url: '/system/client/' + clientId,
16
-    method: 'get'
17
-  })
18
-}
19
-
20
-// 新增终端配置
21
-export function addClient(data) {
22
-  return request({
23
-    url: '/system/client',
24
-    method: 'post',
25
-    data: data
26
-  })
27
-}
28
-
29
-// 修改终端配置
30
-export function updateClient(data) {
31
-  return request({
32
-    url: '/system/client',
33
-    method: 'put',
34
-    data: data
35
-  })
36
-}
37
-
38
-// 删除终端配置
39
-export function delClient(clientId) {
40
-  return request({
41
-    url: '/system/client/' + clientId,
42
-    method: 'delete'
43
-  })
44
-}

+ 10 - 19
ruoyi-ui/src/store/modules/user.js

@@ -1,10 +1,9 @@
1 1
 import { login, logout, getInfo, refreshToken } from '@/api/login'
2
-import { getToken, getRefreshToken, setToken, setRefreshToken, setExpiresIn, removeToken } from '@/utils/auth'
2
+import { getToken, setToken, setExpiresIn, removeToken } from '@/utils/auth'
3 3
 
4 4
 const user = {
5 5
   state: {
6 6
     token: getToken(),
7
-    refresh_token: getRefreshToken(),
8 7
     name: '',
9 8
     avatar: '',
10 9
     roles: [],
@@ -18,9 +17,6 @@ const user = {
18 17
     SET_EXPIRES_IN: (state, time) => {
19 18
       state.expires_in = time
20 19
     },
21
-    SET_REFRESH_TOKEN: (state, token) => {
22
-      state.refresh_token = token
23
-    },
24 20
     SET_NAME: (state, name) => {
25 21
       state.name = name
26 22
     },
@@ -44,12 +40,11 @@ const user = {
44 40
       const uuid = userInfo.uuid
45 41
       return new Promise((resolve, reject) => {
46 42
         login(username, password, code, uuid).then(res => {
47
-          setToken(res.access_token)
48
-          commit('SET_TOKEN', res.access_token)
49
-          setRefreshToken(res.refresh_token)
50
-          commit('SET_REFRESH_TOKEN', res.refresh_token)
51
-          setExpiresIn(res.expires_in)
52
-          commit('SET_EXPIRES_IN', res.expires_in)
43
+          let data = res.data
44
+          setToken(data.access_token)
45
+          commit('SET_TOKEN', data.access_token)
46
+          setExpiresIn(data.expires_in)
47
+          commit('SET_EXPIRES_IN', data.expires_in)
53 48
           resolve()
54 49
         }).catch(error => {
55 50
           reject(error)
@@ -77,17 +72,13 @@ const user = {
77 72
         })
78 73
       })
79 74
     },
80
-    
75
+
81 76
     // 刷新token
82 77
     RefreshToken({commit, state}) {
83 78
       return new Promise((resolve, reject) => {
84
-        refreshToken(state.refresh_token).then(res => {
85
-          setToken(res.access_token)
86
-          commit('SET_TOKEN', res.access_token)
87
-          setRefreshToken(res.refresh_token)
88
-          commit('SET_REFRESH_TOKEN', res.refresh_token)
89
-          setExpiresIn(res.expires_in)
90
-          commit('SET_EXPIRES_IN', res.expires_in)
79
+        refreshToken(state.token).then(res => {
80
+          setExpiresIn(res.data)
81
+          commit('SET_EXPIRES_IN', res.data)
91 82
           resolve()
92 83
         }).catch(error => {
93 84
           reject(error)

+ 0 - 14
ruoyi-ui/src/utils/auth.js

@@ -2,8 +2,6 @@ import Cookies from 'js-cookie'
2 2
 
3 3
 const TokenKey = 'Admin-Token'
4 4
 
5
-const RefreshTokenKey = 'Admin-Refresh-Token'
6
-
7 5
 const ExpiresInKey = 'Admin-Expires-In'
8 6
 
9 7
 export function getToken() {
@@ -18,18 +16,6 @@ export function removeToken() {
18 16
   return Cookies.remove(TokenKey)
19 17
 }
20 18
 
21
-export function getRefreshToken() {
22
-  return Cookies.get(RefreshTokenKey) || ``
23
-}
24
-
25
-export function setRefreshToken(token) {
26
-  return Cookies.set(RefreshTokenKey, token)
27
-}
28
-
29
-export function removeRefreshToken() {
30
-  return Cookies.remove(RefreshTokenKey)
31
-}
32
-
33 19
 export function getExpiresIn() {
34 20
   return Cookies.get(ExpiresInKey) || -1
35 21
 }

+ 1 - 1
ruoyi-ui/src/utils/request.js

@@ -19,7 +19,7 @@ service.interceptors.request.use(config => {
19 19
   // 是否需要设置 token
20 20
   const isToken = (config.headers || {}).isToken === false
21 21
   if (getToken() && !isToken) {
22
-    config.headers['Authorization'] = 'Bearer ' + getToken() // 让每个请求携带自定义token 请根据实际情况自行修改
22
+    config.headers['Authorization'] = 'Bearer ' + getToken() // 让每个请求携带自定义token 请根据实际
23 23
   }
24 24
   return config
25 25
 }, error => {

+ 1 - 1
ruoyi-ui/src/views/index.vue

@@ -88,7 +88,7 @@ export default {
88 88
           return;
89 89
         }
90 90
         const expires_in = getExpiresIn();
91
-        if (expires_in <= 1000 && !this.refreshLock) {
91
+        if (expires_in <= 1200 && !this.refreshLock) {
92 92
           this.refreshLock = true
93 93
           this.$store
94 94
             .dispatch('RefreshToken')

+ 0 - 292
ruoyi-ui/src/views/system/client/index.vue

@@ -1,292 +0,0 @@
1
-<template>
2
-  <div class="app-container">
3
-    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px" @submit.native.prevent>
4
-      <el-form-item label="终端编号" prop="clientId">
5
-        <el-input
6
-          v-model="queryParams.clientId"
7
-          placeholder="终端编号"
8
-          clearable
9
-          size="small"
10
-          @keyup.enter.native="handleQuery"
11
-        />
12
-      </el-form-item>
13
-      <el-form-item>
14
-        <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
15
-        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
16
-      </el-form-item>
17
-    </el-form>
18
-
19
-    <el-row :gutter="10" class="mb8">
20
-      <el-col :span="1.5">
21
-        <el-button
22
-          type="primary"
23
-          icon="el-icon-plus"
24
-          size="mini"
25
-          @click="handleAdd"
26
-          v-hasPermi="['system:client:add']"
27
-        >新增</el-button>
28
-      </el-col>
29
-      <el-col :span="1.5">
30
-        <el-button
31
-          type="success"
32
-          icon="el-icon-edit"
33
-          size="mini"
34
-          :disabled="single"
35
-          @click="handleUpdate"
36
-          v-hasPermi="['system:client:edit']"
37
-        >修改</el-button>
38
-      </el-col>
39
-      <el-col :span="1.5">
40
-        <el-button
41
-          type="danger"
42
-          icon="el-icon-delete"
43
-          size="mini"
44
-          :disabled="multiple"
45
-          @click="handleDelete"
46
-          v-hasPermi="['system:client:remove']"
47
-        >删除</el-button>
48
-      </el-col>
49
-      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
50
-    </el-row>
51
-
52
-    <el-table v-loading="loading" :data="clientList" @selection-change="handleSelectionChange">
53
-      <el-table-column type="selection" width="55" align="center" />
54
-      <el-table-column label="编号" align="center" prop="clientId" />
55
-      <el-table-column label="安全码" align="center" prop="originSecret" :show-overflow-tooltip="true" />
56
-      <el-table-column label="授权范围" align="center" prop="scope" />
57
-      <el-table-column label="授权类型" align="center" prop="authorizedGrantTypes" :formatter="authorizedGrantTypesFormat" :show-overflow-tooltip="true"/>
58
-      <el-table-column label="令牌时效" align="center" prop="accessTokenValidity" />
59
-      <el-table-column label="刷新时效" align="center" prop="refreshTokenValidity" />
60
-      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
61
-        <template slot-scope="scope">
62
-          <el-button
63
-            size="mini"
64
-            type="text"
65
-            icon="el-icon-edit"
66
-            @click="handleUpdate(scope.row)"
67
-            v-hasPermi="['system:client:edit']"
68
-          >修改</el-button>
69
-          <el-button
70
-            size="mini"
71
-            type="text"
72
-            icon="el-icon-delete"
73
-            @click="handleDelete(scope.row)"
74
-            v-hasPermi="['system:client:remove']"
75
-          >删除</el-button>
76
-        </template>
77
-      </el-table-column>
78
-    </el-table>
79
-
80
-    <pagination
81
-      v-show="total>0"
82
-      :total="total"
83
-      :page.sync="queryParams.pageNum"
84
-      :limit.sync="queryParams.pageSize"
85
-      @pagination="getList"
86
-    />
87
-
88
-    <!-- 添加或修改终端对话框 -->
89
-    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
90
-      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
91
-        <el-form-item label="编号" prop="clientId">
92
-          <el-input v-model="form.clientId" placeholder="请输入编号" :disabled="!isAdd" />
93
-        </el-form-item>
94
-        <el-form-item label="安全码" prop="originSecret">
95
-          <el-input v-model="form.originSecret" placeholder="请输入安全码" />
96
-        </el-form-item>
97
-        <el-form-item label="授权范围" prop="scope">
98
-          <el-input v-model="form.scope" placeholder="请输入授权范围" />
99
-        </el-form-item>
100
-        <el-form-item label="授权类型" prop="authorizedGrantTypes">
101
-          <el-checkbox-group v-model="form.authorizedGrantTypes">
102
-            <el-checkbox
103
-              v-for="dict in authorizedGrantTypesOptions"
104
-              :key="dict.dictValue"
105
-              :label="dict.dictValue">
106
-              {{dict.dictLabel}}
107
-            </el-checkbox>
108
-          </el-checkbox-group>
109
-        </el-form-item>
110
-        <el-form-item label="令牌时效" prop="accessTokenValidity">
111
-          <el-input-number v-model="form.accessTokenValidity" controls-position="right" :min="0" />
112
-        </el-form-item>
113
-        <el-form-item label="刷新时效" prop="refreshTokenValidity">
114
-          <el-input-number v-model="form.refreshTokenValidity" controls-position="right" :min="0" />
115
-        </el-form-item>
116
-      </el-form>
117
-      <div slot="footer" class="dialog-footer">
118
-        <el-button type="primary" @click="submitForm">确 定</el-button>
119
-        <el-button @click="cancel">取 消</el-button>
120
-      </div>
121
-    </el-dialog>
122
-  </div>
123
-</template>
124
-
125
-<script>
126
-import { listClient, getClient, delClient, addClient, updateClient } from "@/api/system/client";
127
-
128
-export default {
129
-  name: "Client",
130
-  data() {
131
-    return {
132
-      // 遮罩层
133
-      loading: true,
134
-      // 选中数组
135
-      ids: [],
136
-      // 非单个禁用
137
-      single: true,
138
-      // 非多个禁用
139
-      multiple: true,
140
-      // 显示搜索条件
141
-      showSearch: true,
142
-      // 总条数
143
-      total: 0,
144
-      // 终端表格数据
145
-      clientList: [],
146
-      // 弹出层标题
147
-      title: "",
148
-      // 是否显示弹出层
149
-      open: false,
150
-      // 终端授权类型字典
151
-      authorizedGrantTypesOptions: [],
152
-      // 查询参数
153
-      queryParams: {
154
-        pageNum: 1,
155
-        pageSize: 10,
156
-        clientId: undefined
157
-      },
158
-      // 是否新增
159
-      isAdd: false,
160
-      // 表单参数
161
-      form: {},
162
-      // 表单校验
163
-      rules: {
164
-        clientId: [
165
-          { required: true, message: "编号不能为空", trigger: "blur" }
166
-        ],
167
-        originSecret: [
168
-          { required: true, message: "安全码不能为空", trigger: "blur" }
169
-        ],
170
-        scope: [
171
-          { required: true, message: "授权范围不能为空", trigger: "blur" }
172
-        ],
173
-        authorizedGrantTypes: [
174
-          { required: true, message: "授权类型不能为空", trigger: "blur" }
175
-        ]
176
-      }
177
-    };
178
-  },
179
-  created() {
180
-    this.getList();
181
-    this.getDicts("sys_grant_type").then(response => {
182
-      this.authorizedGrantTypesOptions = response.data;
183
-    });
184
-  },
185
-  methods: {
186
-    /** 查询终端列表 */
187
-    getList() {
188
-      this.loading = true;
189
-      listClient(this.queryParams).then(response => {
190
-        this.clientList = response.rows;
191
-        this.total = response.total;
192
-        this.loading = false;
193
-      });
194
-    },
195
-    // 终端授权类型字典翻译
196
-    authorizedGrantTypesFormat(row, column) {
197
-      return this.selectDictLabels(this.authorizedGrantTypesOptions, row.authorizedGrantTypes);
198
-    },
199
-    // 取消按钮
200
-    cancel() {
201
-      this.open = false;
202
-      this.reset();
203
-    },
204
-    // 表单重置
205
-    reset() {
206
-      this.form = {
207
-        clientId: undefined,
208
-        clientSecret: undefined,
209
-        scope: "server",
210
-        authorizedGrantTypes: [],
211
-        accessTokenValidity: 3600,
212
-        refreshTokenValidity: 7200
213
-      };
214
-      this.resetForm("form");
215
-    },
216
-    /** 搜索按钮操作 */
217
-    handleQuery() {
218
-      this.queryParams.pageNum = 1;
219
-      this.getList();
220
-    },
221
-    /** 重置按钮操作 */
222
-    resetQuery() {
223
-      this.resetForm("queryForm");
224
-      this.handleQuery();
225
-    },
226
-    // 多选框选中数据
227
-    handleSelectionChange(selection) {
228
-      this.ids = selection.map(item => item.clientId);
229
-      this.single = selection.length != 1;
230
-      this.multiple = !selection.length;
231
-    },
232
-    /** 新增按钮操作 */
233
-    handleAdd() {
234
-      this.reset();
235
-      this.open = true;
236
-      this.isAdd = true;
237
-      this.title = "添加终端";
238
-    },
239
-    /** 修改按钮操作 */
240
-    handleUpdate(row) {
241
-      this.reset();
242
-      this.isAdd = false;
243
-      const clientId = row.clientId || this.ids;
244
-      getClient(clientId).then(response => {
245
-        this.form = response.data;
246
-        this.form.authorizedGrantTypes = this.form.authorizedGrantTypes.split(",");
247
-        this.open = true;
248
-        this.title = "修改终端";
249
-      });
250
-    },
251
-    /** 提交按钮 */
252
-    submitForm: function() {
253
-      this.$refs["form"].validate(valid => {
254
-        if (valid) {
255
-          this.form.authorizedGrantTypes = this.form.authorizedGrantTypes.join(",");
256
-          if (!this.isAdd && this.form.clientId != undefined) {
257
-            updateClient(this.form).then(response => {
258
-              if (response.code === 200) {
259
-                this.msgSuccess("修改成功");
260
-                this.open = false;
261
-                this.getList();
262
-              }
263
-            });
264
-          } else {
265
-            addClient(this.form).then(response => {
266
-              if (response.code === 200) {
267
-                this.msgSuccess("新增成功");
268
-                this.open = false;
269
-                this.getList();
270
-              }
271
-            });
272
-          }
273
-        }
274
-      });
275
-    },
276
-    /** 删除按钮操作 */
277
-    handleDelete(row) {
278
-      const clientIds = row.clientId || this.ids;
279
-      this.$confirm('是否确认删除终端编号为"' + clientIds + '"的数据项?', "警告", {
280
-          confirmButtonText: "确定",
281
-          cancelButtonText: "取消",
282
-          type: "warning"
283
-        }).then(function() {
284
-          return delClient(clientIds);
285
-        }).then(() => {
286
-          this.getList();
287
-          this.msgSuccess("删除成功");
288
-        }).catch(function() {});
289
-    }
290
-  }
291
-};
292
-</script>

+ 28 - 54
sql/ry_20200823.sql

@@ -165,19 +165,18 @@ insert into sys_menu values('103',  '部门管理',       '1',   '4',  'dept',
165 165
 insert into sys_menu values('104',  '岗位管理',       '1',   '5',  'post',                                'system/post/index',       1, 'C', '0', '0', 'system:post:list',        'post',          'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '岗位管理菜单');
166 166
 insert into sys_menu values('105',  '字典管理',       '1',   '6',  'dict',                                'system/dict/index',       1, 'C', '0', '0', 'system:dict:list',        'dict',          'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '字典管理菜单');
167 167
 insert into sys_menu values('106',  '参数设置',       '1',   '7',  'config',                              'system/config/index',     1, 'C', '0', '0', 'system:config:list',      'edit',          'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '参数设置菜单');
168
-insert into sys_menu values('107',  '终端设置',       '1',   '8',  'client',                              'system/client/index',     1, 'C', '0', '0', 'system:client:list',      'client',        'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '终端设置菜单');
169
-insert into sys_menu values('108',  '通知公告',       '1',   '9',  'notice',                              'system/notice/index',     1, 'C', '0', '0', 'system:notice:list',      'message',       'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '通知公告菜单');
170
-insert into sys_menu values('109',  '日志管理',       '1',   '10', 'log',                                 'system/log/index',        1, 'M', '0', '0', '',                        'log',           'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '日志管理菜单');
171
-insert into sys_menu values('110',  '定时任务',       '2',   '1',  'job',                                 'monitor/job/index',       1, 'C', '0', '0', 'monitor:job:list',        'job',           'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '定时任务菜单');
172
-insert into sys_menu values('111',  'Sentinel控制台', '2',   '2',  'http://localhost:8718',                '',                       1, 'C', '0', '0', 'monitor:sentinel:list',   'sentinel',      'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '流量控制菜单');
173
-insert into sys_menu values('112',  'Nacos控制台',    '2',   '3',  'http://localhost:8848/nacos',          '',                       1, 'C', '0', '0', 'monitor:nacos:list',      'nacos',         'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '服务治理菜单');
174
-insert into sys_menu values('113',  'Admin控制台',    '2',   '4',  'http://localhost:9100/login',          '',                       1, 'C', '0', '0', 'monitor:server:list',     'server',        'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '服务监控菜单');
175
-insert into sys_menu values('114',  '表单构建',       '3',   '1',  'build',                                'tool/build/index',       1 ,'C', '0', '0', 'tool:build:list',         'build',         'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '表单构建菜单');
176
-insert into sys_menu values('115',  '代码生成',       '3',   '2',  'gen',                                  'tool/gen/index',         1, 'C', '0', '0', 'tool:gen:list',           'code',          'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '代码生成菜单');
177
-insert into sys_menu values('116',  '系统接口',       '3',   '3',  'http://localhost:8080/swagger-ui.html', '',                      1, 'C', '0', '0', 'tool:swagger:list',       'swagger',       'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '系统接口菜单');
168
+insert into sys_menu values('107',  '通知公告',       '1',   '9',  'notice',                              'system/notice/index',     1, 'C', '0', '0', 'system:notice:list',      'message',       'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '通知公告菜单');
169
+insert into sys_menu values('108',  '日志管理',       '1',   '10', 'log',                                 'system/log/index',        1, 'M', '0', '0', '',                        'log',           'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '日志管理菜单');
170
+insert into sys_menu values('109',  '定时任务',       '2',   '1',  'job',                                 'monitor/job/index',       1, 'C', '0', '0', 'monitor:job:list',        'job',           'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '定时任务菜单');
171
+insert into sys_menu values('110',  'Sentinel控制台', '2',   '2',  'http://localhost:8718',                '',                       1, 'C', '0', '0', 'monitor:sentinel:list',   'sentinel',      'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '流量控制菜单');
172
+insert into sys_menu values('111',  'Nacos控制台',    '2',   '3',  'http://localhost:8848/nacos',          '',                       1, 'C', '0', '0', 'monitor:nacos:list',      'nacos',         'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '服务治理菜单');
173
+insert into sys_menu values('112',  'Admin控制台',    '2',   '4',  'http://localhost:9100/login',          '',                       1, 'C', '0', '0', 'monitor:server:list',     'server',        'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '服务监控菜单');
174
+insert into sys_menu values('113',  '表单构建',       '3',   '1',  'build',                                'tool/build/index',       1 ,'C', '0', '0', 'tool:build:list',         'build',         'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '表单构建菜单');
175
+insert into sys_menu values('114',  '代码生成',       '3',   '2',  'gen',                                  'tool/gen/index',         1, 'C', '0', '0', 'tool:gen:list',           'code',          'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '代码生成菜单');
176
+insert into sys_menu values('115',  '系统接口',       '3',   '3',  'http://localhost:8080/swagger-ui.html', '',                      1, 'C', '0', '0', 'tool:swagger:list',       'swagger',       'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '系统接口菜单');
178 177
 -- 三级菜单
179
-insert into sys_menu values('500',  '操作日志', '109', '1', 'operlog',    'system/operlog/index',     1, 'C', '0', '0', 'system:operlog:list',     'form',          'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '操作日志菜单');
180
-insert into sys_menu values('501',  '登录日志', '109', '2', 'logininfor', 'system/logininfor/index',  1, 'C', '0', '0', 'system:logininfor:list',  'logininfor',    'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '登录日志菜单');
178
+insert into sys_menu values('500',  '操作日志', '108', '1', 'operlog',    'system/operlog/index',     1, 'C', '0', '0', 'system:operlog:list',     'form',          'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '操作日志菜单');
179
+insert into sys_menu values('501',  '登录日志', '108', '2', 'logininfor', 'system/logininfor/index',  1, 'C', '0', '0', 'system:logininfor:list',  'logininfor',    'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '登录日志菜单');
181 180
 -- 用户管理按钮
182 181
 insert into sys_menu values('1001', '用户查询', '100', '1',  '', '', 1, 'F', '0', '0', 'system:user:query',          '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
183 182
 insert into sys_menu values('1002', '用户新增', '100', '2',  '', '', 1, 'F', '0', '0', 'system:user:add',            '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
@@ -220,17 +219,11 @@ insert into sys_menu values('1032', '参数新增', '106', '2', '#', '', 1, 'F',
220 219
 insert into sys_menu values('1033', '参数修改', '106', '3', '#', '', 1, 'F', '0', '0', 'system:config:edit',         '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
221 220
 insert into sys_menu values('1034', '参数删除', '106', '4', '#', '', 1, 'F', '0', '0', 'system:config:remove',       '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
222 221
 insert into sys_menu values('1035', '参数导出', '106', '5', '#', '', 1, 'F', '0', '0', 'system:config:export',       '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
223
-insert into sys_menu values('1036', '终端查询', '107', '1', '#', '', 1, 'F', '0', '0', 'system:client:query',        '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
224
-insert into sys_menu values('1037', '终端新增', '107', '2', '#', '', 1, 'F', '0', '0', 'system:client:add',          '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
225
-insert into sys_menu values('1038', '终端修改', '107', '3', '#', '', 1, 'F', '0', '0', 'system:client:edit',         '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
226
-insert into sys_menu values('1039', '终端删除', '107', '4', '#', '', 1, 'F', '0', '0', 'system:client:remove',       '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
227
-insert into sys_menu values('1040', '终端导出', '107', '5', '#', '', 1, 'F', '0', '0', 'system:client:export',       '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
228
-insert into sys_menu values('1041', '公告查询', '108', '1', '#', '', 1, 'F', '0', '0', 'system:notice:query',        '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
229
-insert into sys_menu values('1042', '公告新增', '108', '2', '#', '', 1, 'F', '0', '0', 'system:notice:add',          '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
230
-insert into sys_menu values('1043', '公告修改', '108', '3', '#', '', 1, 'F', '0', '0', 'system:notice:edit',         '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
231
-insert into sys_menu values('1044', '公告删除', '108', '4', '#', '', 1, 'F', '0', '0', 'system:notice:remove',       '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
222
+\-- 通知公告按钮
223
+insert into sys_menu values('1041', '公告查询', '107', '1', '#', '', 1, 'F', '0', '0', 'system:notice:query',        '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
224
+insert into sys_menu values('1042', '公告新增', '107', '2', '#', '', 1, 'F', '0', '0', 'system:notice:add',          '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
225
+insert into sys_menu values('1043', '公告修改', '107', '3', '#', '', 1, 'F', '0', '0', 'system:notice:edit',         '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
226
+insert into sys_menu values('1044', '公告删除', '107', '4', '#', '', 1, 'F', '0', '0', 'system:notice:remove',       '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
232 227
 -- 操作日志按钮
233 228
 insert into sys_menu values('1045', '操作查询', '500', '1', '#', '', 1, 'F', '0', '0', 'system:operlog:query',       '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
234 229
 insert into sys_menu values('1046', '操作删除', '500', '2', '#', '', 1, 'F', '0', '0', 'system:operlog:remove',      '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
@@ -240,19 +233,19 @@ insert into sys_menu values('1048', '登录查询', '501', '1', '#', '', 1, 'F',
240 233
 insert into sys_menu values('1049', '登录删除', '501', '2', '#', '', 1, 'F', '0', '0', 'system:logininfor:remove',   '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
241 234
 insert into sys_menu values('1050', '日志导出', '501', '3', '#', '', 1, 'F', '0', '0', 'system:logininfor:export',   '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
242 235
 -- 定时任务按钮
243
-insert into sys_menu values('1051', '任务查询', '110', '1', '#', '', 1, 'F', '0', '0', 'monitor:job:query',          '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
244
-insert into sys_menu values('1052', '任务新增', '110', '2', '#', '', 1, 'F', '0', '0', 'monitor:job:add',            '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
245
-insert into sys_menu values('1053', '任务修改', '110', '3', '#', '', 1, 'F', '0', '0', 'monitor:job:edit',           '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
246
-insert into sys_menu values('1054', '任务删除', '110', '4', '#', '', 1, 'F', '0', '0', 'monitor:job:remove',         '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
247
-insert into sys_menu values('1055', '状态修改', '110', '5', '#', '', 1, 'F', '0', '0', 'monitor:job:changeStatus',   '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
248
-insert into sys_menu values('1056', '任务导出', '110', '7', '#', '', 1, 'F', '0', '0', 'monitor:job:export',         '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
236
+insert into sys_menu values('1051', '任务查询', '109', '1', '#', '', 1, 'F', '0', '0', 'monitor:job:query',          '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
237
+insert into sys_menu values('1052', '任务新增', '109', '2', '#', '', 1, 'F', '0', '0', 'monitor:job:add',            '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
238
+insert into sys_menu values('1053', '任务修改', '109', '3', '#', '', 1, 'F', '0', '0', 'monitor:job:edit',           '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
239
+insert into sys_menu values('1054', '任务删除', '109', '4', '#', '', 1, 'F', '0', '0', 'monitor:job:remove',         '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
240
+insert into sys_menu values('1055', '状态修改', '109', '5', '#', '', 1, 'F', '0', '0', 'monitor:job:changeStatus',   '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
241
+insert into sys_menu values('1056', '任务导出', '109', '7', '#', '', 1, 'F', '0', '0', 'monitor:job:export',         '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
249 242
 -- 代码生成按钮
250
-insert into sys_menu values('1057', '生成查询', '115', '1', '#', '', 1, 'F', '0', '0', 'tool:gen:query',             '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
251
-insert into sys_menu values('1058', '生成修改', '115', '2', '#', '', 1, 'F', '0', '0', 'tool:gen:edit',              '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
252
-insert into sys_menu values('1059', '生成删除', '115', '3', '#', '', 1, 'F', '0', '0', 'tool:gen:remove',            '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
253
-insert into sys_menu values('1060', '导入代码', '115', '2', '#', '', 1, 'F', '0', '0', 'tool:gen:import',            '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
254
-insert into sys_menu values('1061', '预览代码', '115', '4', '#', '', 1, 'F', '0', '0', 'tool:gen:preview',           '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
255
-insert into sys_menu values('1062', '生成代码', '115', '5', '#', '', 1, 'F', '0', '0', 'tool:gen:code',              '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
243
+insert into sys_menu values('1057', '生成查询', '114', '1', '#', '', 1, 'F', '0', '0', 'tool:gen:query',             '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
244
+insert into sys_menu values('1058', '生成修改', '114', '2', '#', '', 1, 'F', '0', '0', 'tool:gen:edit',              '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
245
+insert into sys_menu values('1059', '生成删除', '114', '3', '#', '', 1, 'F', '0', '0', 'tool:gen:remove',            '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
246
+insert into sys_menu values('1060', '导入代码', '114', '2', '#', '', 1, 'F', '0', '0', 'tool:gen:import',            '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
247
+insert into sys_menu values('1061', '预览代码', '114', '4', '#', '', 1, 'F', '0', '0', 'tool:gen:preview',           '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
248
+insert into sys_menu values('1062', '生成代码', '114', '5', '#', '', 1, 'F', '0', '0', 'tool:gen:code',              '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
256 249
 
257 250
 
258 251
 -- ----------------------------
@@ -684,30 +677,3 @@ create table gen_table_column (
684 677
   update_time       datetime                                   comment '更新时间',
685 678
   primary key (column_id)
686 679
 ) engine=innodb auto_increment=1 comment = '代码生成业务表字段';
687
-
688
-
689
-drop table if exists sys_oauth_client_details;
690
-create table sys_oauth_client_details (
691
-  client_id                  varchar(255)  not null          comment '终端编号',
692
-  resource_ids               varchar(255)  default null      comment '资源ID标识',
693
-  client_secret              varchar(255)  not null          comment '终端安全码',
694
-  scope                      varchar(255)  not null          comment '终端授权范围',
695
-  authorized_grant_types     varchar(255)  not null          comment '终端授权类型',
696
-  web_server_redirect_uri    varchar(255)  default null      comment '服务器回调地址',
697
-  authorities                varchar(255)  default null      comment '访问资源所需权限',
698
-  access_token_validity      int(11)       default null      comment '设定终端的access_token的有效时间值(秒)',
699
-  refresh_token_validity     int(11)       default null      comment '设定终端的refresh_token的有效时间值(秒)',
700
-  additional_information     varchar(4096) default null      comment '附加信息',
701
-  autoapprove                tinyint(4)    default null      comment '是否登录时跳过授权',
702
-  origin_secret              varchar(255)  not null          comment '终端明文安全码',
703
-  primary key (client_id)
704
-) engine=innodb auto_increment=1 comment = '终端配置表';
705
-
706
-insert into sys_oauth_client_details values ('web',    '', '$2a$10$y2hKeELx.z3Sbz.kjQ4wmuiIsv5ZSbUQ1ov4BwFH6ccirP8Knp1uq', 'server', 'password,refresh_token',                    '', NULL, 3600, 7200, NULL, NULL, '123456');
707
-insert into sys_oauth_client_details values ('ruoyi',  '', '$2a$10$y2hKeELx.z3Sbz.kjQ4wmuiIsv5ZSbUQ1ov4BwFH6ccirP8Knp1uq', 'server', 'password,client_credentials,refresh_token', '', NULL, 3600, 7200, NULL, NULL, '123456');

Разлика између датотеке није приказан због своје велике величине
+ 3 - 3
sql/ry_config_20200618.sql