Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
3.7k views
in Technique[技术] by (71.8m points)

token如何确保用户登录的唯一性

使用的shiro-redis-spring-boot-starter的包,但发现前后同一账户两次登录产生的不同token都能进行相关用户权限的操作,这显然不符合逻辑。理想的状态是,当用户再次登录后,只有新生成的token有效,这样防止用户在不同客户端登录忘记退出造成的问题,请问可以实现么?我是新手。


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

数据库或者redis保存userId和token的对应关系。根据token读取userId,老token是读不到userId的,因为对应关系没了。也就实现了唯一登录


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...