This commit is contained in:
chenjianxing 2021-01-26 17:18:20 +08:00
commit 3426a49c8c
9 changed files with 35 additions and 21 deletions

View File

@ -1,5 +1,5 @@
package io.metersphere.commons.constants;
public enum UserSource {
LOCAL, LDAP
LOCAL, LDAP, CAS, OIDC
}

View File

@ -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");

View File

@ -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("");
}

View File

@ -389,8 +389,6 @@ public class JmeterDocumentParser implements DocumentParser {
element.appendChild(createStringProp(document, "HTTPSampler.concurrentPool", "6"));
element.appendChild(createStringProp(document, "HTTPSampler.connect_timeout", ""));
element.appendChild(createStringProp(document, "HTTPSampler.response_timeout", ""));
element.appendChild(createBoolProp(document, "HTTPSampler.image_parser", true));
element.appendChild(createBoolProp(document, "HTTPSampler.concurrentDwn", true));
hashTree.appendChild(element);
// 空的 hashTree
hashTree.appendChild(document.createElement(HASH_TREE_ELEMENT));

View File

@ -0,0 +1,5 @@
package io.metersphere.service;
public interface SSOService {
void logout() throws Exception;
}

View File

@ -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<User> searchUser(String condition) {
return extUserMapper.searchUser(condition);
}
public void logout() throws Exception {
SSOService ssoService = CommonBeanFactory.getBean(SSOService.class);
if (ssoService != null) {
ssoService.logout();
}
}
}

@ -1 +1 @@
Subproject commit a18f543c2be6bcd8521a22094bb11aacc920ece4
Subproject commit ed891ee7503cc1ca4679b4779a5c12e2ffee986d

View File

@ -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();

@ -1 +1 @@
Subproject commit 5abe43dc1f65b529ad59c17bfdc58aea33d23cad
Subproject commit 6d6ed5226849337876ecf55312aa6b5f13ba6472