fix: 修复CSRF-TOKEN过期时没有跳转到登录页的问题
This commit is contained in:
parent
a2bf684ade
commit
d5a0772237
|
@ -7,6 +7,7 @@ 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;
|
||||
|
@ -84,7 +85,7 @@ public class CsrfFilter extends AnonymousFilter {
|
|||
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 RuntimeException("expired token");
|
||||
throw new ExpiredCredentialsException("expired token");
|
||||
}
|
||||
if (!StringUtils.equals(SessionUtils.getUserId(), signatureArray[0])) {
|
||||
throw new RuntimeException("Please check csrf token.");
|
||||
|
|
Loading…
Reference in New Issue