当前位置:网站首页>Detailed explanation of redis's single login

Detailed explanation of redis's single login

2022-07-26 12:46:00 User 9919783

Environmental requirements :redis3.8.2+maven+springBoot+jdk1.8+freemarker Templates

1、 Demand background

At home on weekends , Last colleague suddenly contacted , Let me do a single sign on function for his website , So I sort out the logic first , Realize the function and record .

Single sign in (Single sign on) seeing the name of a thing one thinks of its function , After a website logs in , Other websites do not need users to continue to enter account passwords , And can login without secret , This technology is used very frequently in large websites , For example, Alibaba , When users log in to their system , Each subsystem can log in automatically , If you log in to a treasure , Log in to a monument , You also need a password , You also need to re-enter your password to log in to Taobao , This will definitely result in a very poor user experience , And the authentication logic of the system will also be troublesome , At this time, single sign on appears .

2、 Code instance

This article demonstrates two systems

1、 Ensure that when accessing the login page of the system , Enter the first homepage of the system , When visiting the login page of system 2 , Enter the homepage of system 2 .

2、 When accessing system one or system two , We need to judge redis Whether there is a current user in , If it exists, login without secret .

3、 Logical processing , Before logging in, first judge whether the account and password in the database are correct , If the user logs in correctly on the page , Then it returns login success , And put in redis, Set an expiration time for him .

4、 Guaranteed at redis Other subsystems can log in without secret within the expiration time .

原网站

版权声明
本文为[User 9919783]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/207/202207261145167048.html