若依jwt
Authorization: Bearer eyJhbGciOiJIUzUxMiJ9.eyJsb2dpbl91c2VyX2tleSI6ImRjMDRhOWE2LWE2YTgtNDA1My04MmU4LTRmNmRkMjdjYTA3NCJ9.8ZaOBAnKZ2acfBqZcHvsdRL9DYTaKxeGuyDUglt74HfMuw918p7mdj_uwyeKxA3xMcxi5WNKTOlda33xJ2mX3A login_tokens:dc04a9a6-a6a8-4053-82e8-4f6dd27ca074 {"@type":"com.ruoyi.common.core.domain.model.LoginUser","browser":"Chrome 11","deptId":103,"expireTime":2582223215656,"ipaddr":"127.0.0.1","loginLocation":"内网IP","loginTime":1682221415656,"os":"Windows 10","permissions":Set["*:*:*"],"token":"dc04a9a6-a6a8-4053-82e8-4f6dd27ca074","user":{"admin":true,"avatar":"","createBy":"admin","createTime":"2023-04-17 15:47:39","delFlag":"0","dept":{"ancestors":"0,100,101","children":[],"deptId":103,"deptName":"研发部门","leader":"若依","orderNum":1,"params":{"@type":"java.util.HashMap"},"parentId":101,"status":"0"},"deptId":103,"email":"ry@163.com","loginDate":"2023-04-23 11:38:40","loginIp":"127.0.0.1","nickName":"若依","params":{"@type":"java.util.HashMap"},"password":"$2a$10$7JB720yubVSZvUI0rEqK/.VqGOZTH.ulu33dHOiBE8ByOhJIrdAu2","phonenumber":"15888888888","remark":"管理员","roles":[{"admin":true,"dataScope":"1","deptCheckStrictly":false,"flag":false,"menuCheckStrictly":false,"params":{"@type":"java.util.HashMap"},"roleId":1,"roleKey":"admin","roleName":"超级管理员","roleSort":1,"status":"0"}],"sex":"1","status":"0","userId":1,"userName":"admin"},"userId":1,"username":"admin"}
原理:
生成一个没有过期时间的jwt token,生成一个uuid作为redis的key值,将token存到redis过期key中达到登录过期的效果
加入不过期token的步骤
1、在redis中加入 不过期的key 黄色部分是一个uuid 随机一个都可以
login_tokens:dc04a9a6-a6a8-4053-82e8-4f6dd27ca074
2、expireTime 设置一个很大的值