Explorar o código

1:修改登录token时效为2小时
2:修改token校验逻辑

syh %!s(int64=4) %!d(string=hai) anos
pai
achega
9eff179df5

+ 0 - 1
src/main/java/cn/com/ctop/okr/config/ShiroConfig.java

@@ -47,7 +47,6 @@ public class ShiroConfig {
         filterChainDefinitionMap.put("/sys/wxlogin", "anon");
         filterChainDefinitionMap.put("/callback/qywexin", "anon");
         filterChainDefinitionMap.put("/qywx/departAndUser", "anon");
-        filterChainDefinitionMap.put("/department/queryTreeList", "anon");
         filterChainDefinitionMap.put("/sys/logout", "anon");
 
         // 添加自己的过滤器并且取名为jwt

+ 7 - 9
src/main/java/cn/com/ctop/okr/shiro/authc/ShiroRealm.java

@@ -80,15 +80,13 @@ public class ShiroRealm extends AuthorizingRealm {
      */
     @Override
     protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken auth) throws AuthenticationException {
-        if (!Check.isNull(auth)) {
-            String token = (String) auth.getCredentials();
-            if (token != null) {
-                QYWxUserInfo loginUser = this.checkUserTokenIsEffect(token);
-                return new SimpleAuthenticationInfo(loginUser, token, getName());
-            }
+        String token = (String) auth.getCredentials();
+        if(null == token){
+            throw new AuthenticationException("token为空!");
         }
 
-        return null;
+        QYWxUserInfo loginUser = this.checkUserTokenIsEffect(token);
+        return new SimpleAuthenticationInfo(loginUser, token, getName());
     }
 
     /**
@@ -104,14 +102,14 @@ public class ShiroRealm extends AuthorizingRealm {
         }
 
         // 解密获得username,用于和数据库进行对比
-        String openId = JwtUtil.getUsername(token);  //username即为open_id
+        //username即为open_id
+        String openId = JwtUtil.getUsername(token);
         if (openId == null) {
             log.error("token非法无效!");
             throw new AuthenticationException("token非法无效!");
         }
         // 查询用户信息
         QYWxUserInfo loginUser = new QYWxUserInfo();
-        //CorpUserInfo userInfo = corpUserInfoMapper.getUserInfoByOpenId(openId);
         QYWxUserInfo userInfo = wxUserInfoMapper.getUserInfoByOpenId(openId);
         if (userInfo == null) {
             throw new AuthenticationException("用户不存在!");

+ 2 - 2
src/main/java/cn/com/ctop/okr/utils/JwtUtil.java

@@ -20,8 +20,8 @@ public class JwtUtil {
     /**
      * 过期时间30分钟
      */
-    public static final long EXPIRE_TIME = 2 * 24 * 60 * 60 * 1000;
-//    public static final long EXPIRE_TIME = 1 * 60 * 1000;
+    public static final long EXPIRE_TIME = 2 * 60 * 60 * 1000;
+//    public static final long EXPIRE_TIME = 1 * 30 * 1000;
     //public static final long EXPIRE_TIME = 10 * 1000;