Merge branch 'master' of github.com:metersphere/metersphere
This commit is contained in:
commit
0073ed1307
|
@ -7,7 +7,6 @@ import io.metersphere.commons.utils.SessionUtils;
|
|||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.apache.shiro.authc.ExpiredCredentialsException;
|
||||
import org.apache.shiro.web.filter.authc.AnonymousFilter;
|
||||
import org.apache.shiro.web.util.WebUtils;
|
||||
import org.springframework.core.env.Environment;
|
||||
|
@ -42,12 +41,7 @@ public class CsrfFilter extends AnonymousFilter {
|
|||
// 请求头取出的token value
|
||||
String csrfToken = httpServletRequest.getHeader(TOKEN_NAME);
|
||||
// 校验 token
|
||||
try {
|
||||
validateToken(csrfToken);
|
||||
} catch (ExpiredCredentialsException e) {
|
||||
((HttpServletResponse) response).setHeader("Authentication-Status", "invalid");
|
||||
return true;
|
||||
}
|
||||
validateToken(csrfToken);
|
||||
// 校验 referer
|
||||
validateReferer(httpServletRequest);
|
||||
return true;
|
||||
|
@ -80,18 +74,6 @@ public class CsrfFilter extends AnonymousFilter {
|
|||
if (signatureArray.length != 3) {
|
||||
throw new RuntimeException("invalid token");
|
||||
}
|
||||
|
||||
long signatureTime;
|
||||
try {
|
||||
signatureTime = Long.parseLong(signatureArray[2]);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
Environment env = CommonBeanFactory.getBean(Environment.class);
|
||||
long timeout = env.getProperty("session.timeout", Long.class, 43200L);
|
||||
if (Math.abs(System.currentTimeMillis() - signatureTime) > timeout * 1000) {
|
||||
throw new ExpiredCredentialsException("expired token");
|
||||
}
|
||||
if (!StringUtils.equals(SessionUtils.getUserId(), signatureArray[0])) {
|
||||
throw new RuntimeException("Please check csrf token.");
|
||||
}
|
||||
|
|
|
@ -206,7 +206,7 @@ public class TestPlanService {
|
|||
}
|
||||
else { // 有修改字段的调用,为保证将某些时间置null的情况,使用updateByPrimaryKey
|
||||
extScheduleMapper.updateNameByResourceID(testPlan.getId(), testPlan.getName());// 同步更新该测试的定时任务的name
|
||||
i = testPlanMapper.updateByPrimaryKey(testPlan); // 更新
|
||||
i = testPlanMapper.updateByPrimaryKeyWithBLOBs(testPlan); // 更新
|
||||
}
|
||||
if (!StringUtils.isBlank(testPlan.getStatus())) {
|
||||
BeanUtils.copyBean(testPlans, getTestPlan(testPlan.getId()));
|
||||
|
|
Loading…
Reference in New Issue