diff --git a/backend/src/main/java/io/metersphere/commons/constants/UserSource.java b/backend/src/main/java/io/metersphere/commons/constants/UserSource.java index ade69a3b98..c4a520d590 100644 --- a/backend/src/main/java/io/metersphere/commons/constants/UserSource.java +++ b/backend/src/main/java/io/metersphere/commons/constants/UserSource.java @@ -1,5 +1,5 @@ package io.metersphere.commons.constants; public enum UserSource { - LOCAL, LDAP + LOCAL, LDAP, CAS, OIDC } diff --git a/backend/src/main/java/io/metersphere/commons/utils/ShiroUtils.java b/backend/src/main/java/io/metersphere/commons/utils/ShiroUtils.java index 5dabde8a98..f6f8fd71ca 100644 --- a/backend/src/main/java/io/metersphere/commons/utils/ShiroUtils.java +++ b/backend/src/main/java/io/metersphere/commons/utils/ShiroUtils.java @@ -28,6 +28,7 @@ public class ShiroUtils { filterChainDefinitionMap.put("/authsource/list/allenable", "anon"); filterChainDefinitionMap.put("/sso/signin", "anon"); filterChainDefinitionMap.put("/sso/callback", "anon"); + // for swagger filterChainDefinitionMap.put("/swagger-ui.html", "anon"); filterChainDefinitionMap.put("/swagger-ui/**", "anon"); diff --git a/backend/src/main/java/io/metersphere/controller/LoginController.java b/backend/src/main/java/io/metersphere/controller/LoginController.java index a3a73e2577..2850f8ff60 100644 --- a/backend/src/main/java/io/metersphere/controller/LoginController.java +++ b/backend/src/main/java/io/metersphere/controller/LoginController.java @@ -56,13 +56,9 @@ public class LoginController { } @GetMapping(value = "/signout") - public ResultHolder logout() { - String ssoMode = env.getProperty("sso.mode"); - if (ssoMode != null && StringUtils.equalsIgnoreCase(SsoMode.CAS.name(), ssoMode)) { - return ResultHolder.error("sso"); - } else { - SecurityUtils.getSubject().logout(); - } + public ResultHolder logout() throws Exception { + userService.logout(); + SecurityUtils.getSubject().logout(); return ResultHolder.success(""); } diff --git a/backend/src/main/java/io/metersphere/service/SSOService.java b/backend/src/main/java/io/metersphere/service/SSOService.java new file mode 100644 index 0000000000..bb727c0fbd --- /dev/null +++ b/backend/src/main/java/io/metersphere/service/SSOService.java @@ -0,0 +1,5 @@ +package io.metersphere.service; + +public interface SSOService { + void logout() throws Exception; +} diff --git a/backend/src/main/java/io/metersphere/service/UserService.java b/backend/src/main/java/io/metersphere/service/UserService.java index c34ee15bb0..5c59cffa03 100644 --- a/backend/src/main/java/io/metersphere/service/UserService.java +++ b/backend/src/main/java/io/metersphere/service/UserService.java @@ -10,6 +10,7 @@ import io.metersphere.commons.constants.UserStatus; import io.metersphere.commons.exception.MSException; import io.metersphere.commons.user.SessionUser; import io.metersphere.commons.utils.CodingUtil; +import io.metersphere.commons.utils.CommonBeanFactory; import io.metersphere.commons.utils.SessionUtils; import io.metersphere.controller.ResultHolder; import io.metersphere.controller.request.LoginRequest; @@ -608,4 +609,11 @@ public class UserService { public List searchUser(String condition) { return extUserMapper.searchUser(condition); } + + public void logout() throws Exception { + SSOService ssoService = CommonBeanFactory.getBean(SSOService.class); + if (ssoService != null) { + ssoService.logout(); + } + } } diff --git a/backend/src/main/java/io/metersphere/xpack b/backend/src/main/java/io/metersphere/xpack index a18f543c2b..ed891ee750 160000 --- a/backend/src/main/java/io/metersphere/xpack +++ b/backend/src/main/java/io/metersphere/xpack @@ -1 +1 @@ -Subproject commit a18f543c2be6bcd8521a22094bb11aacc920ece4 +Subproject commit ed891ee7503cc1ca4679b4779a5c12e2ffee986d diff --git a/frontend/src/business/components/common/head/HeaderUser.vue b/frontend/src/business/components/common/head/HeaderUser.vue index c096706f44..bd17eb32a4 100644 --- a/frontend/src/business/components/common/head/HeaderUser.vue +++ b/frontend/src/business/components/common/head/HeaderUser.vue @@ -28,6 +28,9 @@ import {getCurrentUser} from "@/common/js/utils"; import AboutUs from "./AboutUs"; import axios from "axios"; +const requireComponent = require.context('@/business/components/xpack/', true, /\.vue$/); +const auth = requireComponent.keys().length > 0 ? requireComponent("./auth/Auth.vue") : {}; + export default { name: "MsUser", components: {AboutUs}, @@ -42,6 +45,17 @@ export default { } }, methods: { + logout: function () { + axios.get("/signout").then(response => { + if (response.data.success) { + localStorage.clear(); + window.location.href = "/login"; + } + }).catch(error => { + localStorage.clear(); + window.location.href = "/login"; + }); + }, handleCommand(command) { switch (command) { case "personal": @@ -49,15 +63,7 @@ export default { this.$router.push('/setting/personsetting').catch(error => error); break; case "logout": - axios.get("/signout").then(response => { - if (response.data.success) { - localStorage.clear(); - window.location.href = "/login"; - } - }).catch(error => { - localStorage.clear(); - window.location.href = "/login"; - }); + this.logout(); break; case "about": this.$refs.aboutUs.open(); diff --git a/frontend/src/business/components/xpack b/frontend/src/business/components/xpack index 5abe43dc1f..6d6ed52268 160000 --- a/frontend/src/business/components/xpack +++ b/frontend/src/business/components/xpack @@ -1 +1 @@ -Subproject commit 5abe43dc1f65b529ad59c17bfdc58aea33d23cad +Subproject commit 6d6ed5226849337876ecf55312aa6b5f13ba6472