Przeglądaj źródła

统一认证注销登录

xyg 2 lat temu
rodzic
commit
88499cd3e4

+ 4 - 4
spring-cloud/configer/src/main/resources/config/dev/gateway-dev.yml

@@ -88,7 +88,7 @@ filter:
     /safetyInfor/getWebSafetyStatusByOrg,/OfficeVirus/getOfficeSafetyInfo,/GuaranteeGroup/getAllGuaranteeGroup,/monitoringResources/getMonitorListByName,/monitoringResources/creatRelay,\
     /monitoringResources/closeAllRelay,/monitoringResources/getStreamForKaiKang,/SystemRisk/GetSystemRiskList,/SystemRisk/getSysInfoByOffice,/flat/door/personRegister,/flat/sendMessage,/businessSystem/getSystemInfoByShow,\
     /commandTranscription/insertCommandTranscription,/safetyInfor/analysisWebSafetyInfo,/safetyInfor/analysisSafetyStatus,\
-    /hotSearch/getAllHotSearch"
+    /hotSearch/getAllHotSearch,/commandTranscription/insertCommandTranscription"
 
   # 不需要过参数过滤器的uri
   parameter:
@@ -102,7 +102,7 @@ filter:
     /AttackEvent/getAttackEventByInfo,/AttackType/getAttackTypeByMonth,/SystemAttacked/getSystemAttackedByInfo,/businessSystem/getSystemInfoByVoiceKeyword,\
     /safetyInfor/getWebSafetyStatusByOrg,/OfficeVirus/getOfficeSafetyInfo,/GuaranteeGroup/getAllGuaranteeGroup,/monitoringResources/getMonitorListByName,/monitoringResources/creatRelay,/monitoringResources/closeAllRelay,\
     /SystemRisk/GetSystemRiskList,/SystemRisk/getSysInfoByOffice,/monitoringResources/getStreamForKaiKang,/businessSystem/getSystemInfoByShow,\
-    /safetyInfor/analysisWebSafetyInfo,/safetyInfor/analysisSafetyStatus,/hotSearch/getAllHotSearch"
+    /safetyInfor/analysisWebSafetyInfo,/safetyInfor/analysisSafetyStatus,/hotSearch/getAllHotSearch,/commandTranscription/insertCommandTranscription"
 
   # 不需要过返回封装过滤器的uri
   response:
@@ -116,12 +116,12 @@ filter:
     /AttackEvent/getAttackEventByInfo,/AttackType/getAttackTypeByMonth,/SystemAttacked/getSystemAttackedByInfo,/businessSystem/getSystemInfoByVoiceKeyword,\
     /safetyInfor/getWebSafetyStatusByOrg,/OfficeVirus/getOfficeSafetyInfo,/GuaranteeGroup/getAllGuaranteeGroup,/monitoringResources/getMonitorListByName,/monitoringResources/creatRelay,/monitoringResources/closeAllRelay,\
     /SystemRisk/GetSystemRiskList,/SystemRisk/getSysInfoByOffice,/monitoringResources/getStreamForKaiKang,/flat/door/personRegister,/flat/sendMessage,/businessSystem/getSystemInfoByShow,\
-    /commandTranscription/insertCommandTranscription,/safetyInfor/analysisWebSafetyInfo,/safetyInfor/analysisSafetyStatus,/hotSearch/getAllHotSearch"
+    /commandTranscription/insertCommandTranscription,/safetyInfor/analysisWebSafetyInfo,/safetyInfor/analysisSafetyStatus,/hotSearch/getAllHotSearch,/commandTranscription/insertCommandTranscription"
 
   # 登录接口
   login:
 #    skip-uri: "/user/userLogin,/flat/guide/login"
-    skip-uri: /user/userLogin,/flat/guide/login
+    skip-uri: /user/userLogin,/flat/guide/login,/ssoUser/userLogin,/user/loginBySsoAccount
   header:
     ceshi: amQrd2pkYyBzZ2hmZGpoZGZuamRmZ25kZ2RzaGRmaGpzZGdhZ2ZzZGhkc2Z4enhzYXNkYXNnaHJkZmVzZ2h2amo=
     

+ 4 - 4
spring-cloud/configer/src/main/resources/config/prod/gateway-prod.yml

@@ -87,7 +87,7 @@ filter:
     /AttackEvent/getAttackEventByInfo,/AttackType/getAttackTypeByMonth,/SystemAttacked/getSystemAttackedByInfo,/businessSystem/getSystemInfoByVoiceKeyword,\
     /safetyInfor/getWebSafetyStatusByOrg,/OfficeVirus/getOfficeSafetyInfo,/GuaranteeGroup/getAllGuaranteeGroup,/monitoringResources/getMonitorListByName,/monitoringResources/creatRelay,\
     /monitoringResources/closeAllRelay,/monitoringResources/getStreamForKaiKang,/SystemRisk/GetSystemRiskList,/SystemRisk/getSysInfoByOffice,/flat/door/personRegister,/flat/sendMessage,/businessSystem/getSystemInfoByShow,\
-    /safetyInfor/analysisWebSafetyInfo,/safetyInfor/analysisSafetyStatus,/hotSearch/getAllHotSearch"
+    /safetyInfor/analysisWebSafetyInfo,/safetyInfor/analysisSafetyStatus,/hotSearch/getAllHotSearch,/commandTranscription/insertCommandTranscription"
 
   # 不需要过参数过滤器的uri
   parameter:
@@ -101,7 +101,7 @@ filter:
     /AttackEvent/getAttackEventByInfo,/AttackType/getAttackTypeByMonth,/SystemAttacked/getSystemAttackedByInfo,/businessSystem/getSystemInfoByVoiceKeyword,\
     /safetyInfor/getWebSafetyStatusByOrg,/OfficeVirus/getOfficeSafetyInfo,/GuaranteeGroup/getAllGuaranteeGroup,/monitoringResources/getMonitorListByName,/monitoringResources/creatRelay,/monitoringResources/closeAllRelay,\
     /SystemRisk/GetSystemRiskList,/SystemRisk/getSysInfoByOffice,/monitoringResources/getStreamForKaiKang,/businessSystem/getSystemInfoByShow,/safetyInfor/analysisWebSafetyInfo,\
-    /safetyInfor/analysisSafetyStatus,/hotSearch/getAllHotSearch"
+    /safetyInfor/analysisSafetyStatus,/hotSearch/getAllHotSearch,/commandTranscription/insertCommandTranscription"
 
   # 不需要过返回封装过滤器的uri
   response:
@@ -115,9 +115,9 @@ filter:
     /AttackEvent/getAttackEventByInfo,/AttackType/getAttackTypeByMonth,/SystemAttacked/getSystemAttackedByInfo,/businessSystem/getSystemInfoByVoiceKeyword,\
     /safetyInfor/getWebSafetyStatusByOrg,/OfficeVirus/getOfficeSafetyInfo,/GuaranteeGroup/getAllGuaranteeGroup,/monitoringResources/getMonitorListByName,/monitoringResources/creatRelay,/monitoringResources/closeAllRelay,\
     /SystemRisk/GetSystemRiskList,/SystemRisk/getSysInfoByOffice,/monitoringResources/getStreamForKaiKang,/flat/door/personRegister,/flat/sendMessage,/businessSystem/getSystemInfoByShow,/safetyInfor/analysisWebSafetyInfo,\
-    /safetyInfor/analysisSafetyStatus,/hotSearch/getAllHotSearch"
+    /safetyInfor/analysisSafetyStatus,/hotSearch/getAllHotSearch,/commandTranscription/insertCommandTranscription"
   # 登录接口
   login:
-    skip-uri: /user/userLogin,/flat/guide/login
+    skip-uri: /user/userLogin,/flat/guide/login,/ssoUser/userLogin,/user/loginBySsoAccount
   header:
     ceshi: amQrd2pkYyBzZ2hmZGpoZGZuamRmZ25kZ2RzaGRmaGpzZGdhZ2ZzZGhkc2Z4enhzYXNkYXNnaHJkZmVzZ2h2amo=

+ 7 - 3
spring-cloud/server-basic/src/main/java/com/jd/controller/SsoUserController.java

@@ -140,12 +140,16 @@ public class SsoUserController {
 
     /**
      * 注销
-     * @param userId 用户id
+     * @param clientId     客户机id
+     * @param loginAccount 登录账户
      * @return {@link Map}<{@link String}, {@link Object}>
      */
     @GetMapping("logout")
     @ApiOperation("退出登录")
-    public Map<String, Object> logout(Integer userId) {
-        return ssoUserService.logout(userId);
+    public Map<String, Object> logout(String clientId, String loginAccount) {
+        if (Blank.isEmpty(clientId, loginAccount)) {
+            return SendUtil.send(false, ConstString.REQUEST_WRONGPARAMS);
+        }
+        return ssoUserService.logout(clientId, loginAccount);
     }
 }

+ 3 - 2
spring-cloud/server-basic/src/main/java/com/jd/service/SsoUserService.java

@@ -65,8 +65,9 @@ public interface SsoUserService {
 
     /**
      * 注销
-     * @param userId 用户id
+     * @param clientId     客户机id
+     * @param loginAccount 登录账户
      * @return {@link Map}<{@link String}, {@link Object}>
      */
-    Map<String, Object> logout(Integer userId);
+    Map<String, Object> logout(String clientId, String loginAccount);
 }

+ 8 - 3
spring-cloud/server-basic/src/main/java/com/jd/service/impl/SsoUserServiceImpl.java

@@ -151,15 +151,20 @@ public class SsoUserServiceImpl implements SsoUserService {
     }
 
     @Override
-    public Map<String, Object> logout(Integer userId) {
+    public Map<String, Object> logout(String clientId, String loginAccount) {
+        Map<String, Object> user = ssoUserMapper.getSsoUserInfoByAccount(loginAccount, clientId);
+        if (Blank.isEmpty(user)) {
+            return SendUtil.send(false, "用户不存在");
+        }
         // 获取当前登录用户信息
-        Map<String, Object> loginUserInfo = Convert.toMap(String.class, Object.class, redisTemplate.opsForValue().get(Convert.toStr(userId)));
+        Map<String, Object> loginUserInfo = Convert.toMap(String.class, Object.class, redisTemplate.opsForValue().get(Convert.toStr(user.get("user_id"))));
         // 清除当前用户的token
         if (Blank.isNotEmpty(loginUserInfo)) {
             String token = Convert.toStr(loginUserInfo.get("access_token"));
             authClient.revokeToken(token);
         }
-        redisTemplate.delete(Convert.toStr(userId));
+        redisTemplate.delete(Convert.toStr(user.get("user_id")));
+        redisTemplate.delete(clientId + loginAccount);
         return SendUtil.send(true);
     }
 }

+ 19 - 3
spring-cloud/server-page/src/main/resources/static/page/js/basic/index.js

@@ -301,9 +301,25 @@ function logout(userId) {
 			"userId": userId
 		},
 		success: function(json) {
-			sessionStorage.clear();
-			layer.close(index);
-			window.location = "login.html";
+			sessionStorage.ACCESS_TOKEN = sessionStorage.SSO_ACCESS_TOKEN;
+			sessionStorage.TOKEN_TYPE = sessionStorage.SSO_TOKEN_TYPE;
+			ly.ajax({
+				type: 'GET',
+				url: PAGE_BASIC + '/ssoUser/logout',
+				dataType: 'json',
+				data: {
+					clientId: sessionStorage.SSO_CLIENT_ID,
+					loginAccount: sessionStorage.SSO_ACCOUNT
+				},
+				success: function(json) {
+					sessionStorage.clear();
+					layer.close(index);
+					window.location = "login.html";
+				},
+				error: function(msg) {
+					layer.close(index);
+				}
+			});
 		},
 		error: function(msg) {
 			layer.close(index);

+ 1 - 1
spring-cloud/server-page/src/main/resources/static/page/login.html

@@ -110,7 +110,7 @@
 	</style>
 	</head>
 	<script>
-		window.location.href = 'http://192.168.0.235:8888/sso/login.html?clientId=I34U4QF4D&redirect=http://192.168.0.235:8888/page/temp.html';
+		window.location.href = 'http://192.168.0.235:8888/sso/login.html?clientId=I34U4QF4D&redirect=http://192.168.0.235:8888/page/preLogin.html';
 	</script>
 	<body>
 		<div class="loginBox layui-form">

+ 4 - 0
spring-cloud/server-page/src/main/resources/static/page/temp.html → spring-cloud/server-page/src/main/resources/static/page/preLogin.html

@@ -23,6 +23,10 @@
             let nameData = JSON.parse(wName);
             sessionStorage.ACCESS_TOKEN = nameData.ACCESS_TOKEN;
             sessionStorage.TOKEN_TYPE = nameData.TOKEN_TYPE;
+            sessionStorage.SSO_ACCESS_TOKEN = nameData.ACCESS_TOKEN;
+            sessionStorage.SSO_TOKEN_TYPE = nameData.TOKEN_TYPE;
+            sessionStorage.SSO_CLIENT_ID = nameData.CLIENT_ID;
+            sessionStorage.SSO_ACCOUNT = nameData.ACCOUNT;
 
             let index = layer.load(2);
             ly.ajax({