Merge branch 'v1.3' of https://github.com/metersphere/server into v1.3
This commit is contained in:
commit
0cf960b7d1
|
@ -1,10 +1,14 @@
|
|||
package io.metersphere.commons.utils;
|
||||
|
||||
import io.metersphere.commons.user.SessionUser;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.apache.shiro.session.Session;
|
||||
import org.apache.shiro.session.mgt.DefaultSessionManager;
|
||||
import org.apache.shiro.subject.Subject;
|
||||
import org.apache.shiro.subject.support.DefaultSubjectContext;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
|
||||
|
@ -26,6 +30,30 @@ public class SessionUtils {
|
|||
}
|
||||
}
|
||||
|
||||
private static Session getSessionByUsername(String username) {
|
||||
DefaultSessionManager sessionManager = CommonBeanFactory.getBean(DefaultSessionManager.class);
|
||||
Collection<Session> sessions = sessionManager.getSessionDAO().getActiveSessions();
|
||||
for (Session session : sessions) {
|
||||
if (null != session && StringUtils.equals(String.valueOf(session.getAttribute(DefaultSubjectContext.PRINCIPALS_SESSION_KEY)), username)) {
|
||||
return session;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 踢除用户
|
||||
*
|
||||
* @param username
|
||||
*/
|
||||
public static void kickOutUser(String username) {
|
||||
Session session = getSessionByUsername(username);
|
||||
if (session != null) {
|
||||
DefaultSessionManager sessionManager = CommonBeanFactory.getBean(DefaultSessionManager.class);
|
||||
sessionManager.getSessionDAO().delete(session);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
public static void putUser(SessionUser sessionUser) {
|
||||
SecurityUtils.getSubject().getSession().setAttribute(ATTR_USER, sessionUser);
|
||||
|
|
|
@ -2,7 +2,6 @@ package io.metersphere.config;
|
|||
|
||||
import io.metersphere.commons.utils.ShiroUtils;
|
||||
import io.metersphere.security.ApiKeyFilter;
|
||||
import io.metersphere.security.LoginFilter;
|
||||
import io.metersphere.security.ShiroDBRealm;
|
||||
import org.apache.shiro.cache.MemoryConstrainedCacheManager;
|
||||
import org.apache.shiro.session.mgt.SessionManager;
|
||||
|
@ -36,7 +35,7 @@ public class ShiroConfig implements EnvironmentAware {
|
|||
@Bean
|
||||
public ShiroFilterFactoryBean getShiroFilterFactoryBean(DefaultWebSecurityManager sessionManager) {
|
||||
ShiroFilterFactoryBean shiroFilterFactoryBean = new ShiroFilterFactoryBean();
|
||||
shiroFilterFactoryBean.getFilters().put("authc", new LoginFilter());
|
||||
// shiroFilterFactoryBean.getFilters().put("authc", new LoginFilter());
|
||||
shiroFilterFactoryBean.setLoginUrl("/login");
|
||||
shiroFilterFactoryBean.setSecurityManager(sessionManager);
|
||||
shiroFilterFactoryBean.setUnauthorizedUrl("/403");
|
||||
|
@ -45,7 +44,8 @@ public class ShiroConfig implements EnvironmentAware {
|
|||
shiroFilterFactoryBean.getFilters().put("apikey", new ApiKeyFilter());
|
||||
Map<String, String> filterChainDefinitionMap = shiroFilterFactoryBean.getFilterChainDefinitionMap();
|
||||
ShiroUtils.loadBaseFilterChain(filterChainDefinitionMap);
|
||||
filterChainDefinitionMap.put("/**", "apikey, authc");
|
||||
// filterChainDefinitionMap.put("/**", "apikey, authc");
|
||||
filterChainDefinitionMap.put("/**", "apikey");
|
||||
return shiroFilterFactoryBean;
|
||||
}
|
||||
|
||||
|
|
|
@ -63,6 +63,8 @@ public class UserController {
|
|||
@RequiresRoles(RoleConstants.ADMIN)
|
||||
public void deleteUser(@PathVariable(value = "userId") String userId) {
|
||||
userService.deleteUser(userId);
|
||||
// 踢掉在线用户
|
||||
SessionUtils.kickOutUser(userId);
|
||||
}
|
||||
|
||||
@PostMapping("/special/update")
|
||||
|
|
|
@ -42,12 +42,12 @@ public class MailService {
|
|||
@Resource
|
||||
private SystemParameterService systemParameterService;
|
||||
|
||||
public void sendPerformanceNotification(List<NoticeDetail> noticeList, String status, LoadTestWithBLOBs loadTest) {
|
||||
public void sendPerformanceNotification(List<NoticeDetail> noticeList, String status, LoadTestWithBLOBs loadTest, String id) {
|
||||
BaseSystemConfigDTO baseSystemConfigDTO = systemParameterService.getBaseInfo();
|
||||
Map<String, String> context = new HashMap<>();
|
||||
context.put("title", "Performance" + Translator.get("timing_task_result_notification"));
|
||||
context.put("testName", loadTest.getName());
|
||||
context.put("id", loadTest.getId());
|
||||
context.put("id", id);
|
||||
context.put("type", "performance");
|
||||
context.put("url", baseSystemConfigDTO.getUrl());
|
||||
String performanceTemplate = "";
|
||||
|
|
|
@ -242,7 +242,7 @@ public class PerformanceTestService {
|
|||
if (request.getTriggerMode().equals("SCHEDULE")) {
|
||||
try {
|
||||
noticeList = noticeService.queryNotice(loadTest.getId());
|
||||
mailService.sendPerformanceNotification(noticeList, PerformanceTestStatus.Completed.name(), loadTest);
|
||||
mailService.sendPerformanceNotification(noticeList, PerformanceTestStatus.Completed.name(), loadTest, engine.getReportId());
|
||||
} catch (Exception e) {
|
||||
LogUtil.error(e.getMessage(), e);
|
||||
}
|
||||
|
@ -321,7 +321,7 @@ public class PerformanceTestService {
|
|||
loadTestMapper.updateByPrimaryKeySelective(loadTest);
|
||||
if (triggerMode.equals("SCHEDULE")) {
|
||||
noticeList = noticeService.queryNotice(loadTest.getId());
|
||||
mailService.sendPerformanceNotification(noticeList, loadTest.getStatus(), loadTest);
|
||||
mailService.sendPerformanceNotification(noticeList, loadTest.getStatus(), loadTest, loadTest.getId());
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
|
@ -449,7 +449,7 @@ public class PerformanceTestService {
|
|||
if (loadTestReport.getTriggerMode().equals("SCHEDULE")) {
|
||||
try {
|
||||
noticeList = noticeService.queryNotice(loadTest.getId());
|
||||
mailService.sendPerformanceNotification(noticeList, loadTestReport.getStatus(), loadTest);
|
||||
mailService.sendPerformanceNotification(noticeList, loadTestReport.getStatus(), loadTest, loadTestReport.getId());
|
||||
} catch (Exception e) {
|
||||
LogUtil.error(e.getMessage(), e);
|
||||
}
|
||||
|
|
|
@ -82,7 +82,8 @@ public class XmindCaseParser {
|
|||
for (int i = 0; i < nodes.length; i++) {
|
||||
if (i != 0 && StringUtils.equals(nodes[i].trim(), "")) {
|
||||
process.append(Translator.get("module_not_null") + "; ");
|
||||
break;
|
||||
} else if (nodes[i].trim().length() > 30) {
|
||||
process.append(nodes[i].trim() + ":" + Translator.get("test_track.length_less_than") + "30 ;");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -236,6 +237,9 @@ public class XmindCaseParser {
|
|||
if (i != 0 && StringUtils.equals(nodes[i].trim(), "")) {
|
||||
stringBuilder.append(Translator.get("module_not_null") + "; ");
|
||||
break;
|
||||
} else if (nodes[i].trim().length() > 30) {
|
||||
stringBuilder.append(nodes[i].trim() + ":" + Translator.get("test_track.length_less_than") + "30 ;");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -275,7 +279,6 @@ public class XmindCaseParser {
|
|||
} else {
|
||||
item.setPath(item.getTitle());
|
||||
if (item.getChildren() != null && !item.getChildren().getAttached().isEmpty()) {
|
||||
item.setPath(item.getTitle());
|
||||
recursion(processBuffer, item, 1, item.getChildren().getAttached());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -157,3 +157,4 @@ import_xmind_not_found=Test case not found
|
|||
license_valid_license_error=Authorization authentication failed
|
||||
timing_task_result_notification=Timing task result notification
|
||||
test_review_task_notice=Test review task notice
|
||||
test_track.length_less_than=The title is too long, the length must be less than
|
||||
|
|
|
@ -157,5 +157,5 @@ license_valid_license_error=授权认证失败
|
|||
import_xmind_not_found=未找到测试用例
|
||||
timing_task_result_notification=定时任务结果通知
|
||||
test_review_task_notice=测试评审任务通知
|
||||
|
||||
test_track.length_less_than=标题过长,字数必须小于
|
||||
|
||||
|
|
|
@ -157,4 +157,5 @@ email_subject=MeterSphere定時任務結果通知
|
|||
import_xmind_count_error=思維導圖導入用例數量不能超過 500 條
|
||||
import_xmind_not_found=未找到测试用例
|
||||
timing_task_result_notification=定時任務結果通知
|
||||
test_review_task_notice=測試評審任務通知
|
||||
test_review_task_notice=測試評審任務通知
|
||||
test_track.length_less_than=標題過長,字數必須小於
|
Loading…
Reference in New Issue