当前位置:网站首页>Three ways of single sign-on
Three ways of single sign-on
2022-07-31 10:17:00 【xiaoweiwei99】
Table of Contents
Three, three of single sign-ona common way?
1. Implementation of session broadcast mechanism
2. Use cookie+redis to achieve
2.1 Log in to any module in the project, after logging in, put the data in these two places
3 use token implementation (recommended)
I. Single server mode login
Use the session object to implement
*After the login is successful, put the user data into the session session.setAttribute("user",user)
*Determine whether to log in, get data from the session, you can get the login session.getAttribute("user")
Second, cluster deployment
Single Sign On, or SSO for short, is one of the more popular solutions for enterprise business integration.The definition of SSO is in multiple applicationsIn the system, users only need to log in once to access all mutually trusted application systems.
Three common methods of single sign-on
1.session broadcast mechanism implementation
After logging in to a module in a cluster, and then copying n copies of the session and sending it to other modules in the cluster, one login is realized, and it is available everywhere, but the disadvantage is that it costs a lot and is not recommended.
2. Implemented using cookie+redis
2.1 Log in to any module in the project, after logging in, put the data in these two places
(1) redis: In key: generate a unique random value (ip, user id, etc.), In value: user data
(2) cookie: put the key value generated in redis into the cookie
2.2 Access other modules in the project, send requests with cookies, get cookie values, and do things with cookies
Get the value of the cookie, go to redis to query, query according to the key, if the query data is to log in
3 is implemented using token (recommended)
What is 3.1token
Generate a string according to certain rules, the string can contain user information
3.2 implementation method
1. Log in to a certain module of the project, after logging in, generate a string according to the rules, include the user after login into the generated string, and return the string
(1) The string can be returned through a cookie
(2) Return the string through the address bar
2. Go to other modules of the project, and each visit will bring the generated string in the address bar, obtain the address string in the access module, and obtain user information according to the string.Sign in if you can get it
As shown below
Let me introduce myself first. The editor graduated from Shanghai Jiaotong University in 2013. I worked in a small company and went to big factories such as Huawei and OPPO. I joined Alibaba in 2018, until now.I know that most junior and intermediate java engineers want to upgrade their skills, they often need to explore their own growth or sign up to study, but for training institutions, the tuition fee is nearly 10,000 yuan, which is really stressful.Self-learning that is not systematic is very inefficient and lengthy, and it is easy to hit the ceiling and the technology stops.Therefore, I collected a "full set of learning materials for java development" for everyone. The original intention is also very simple. I hope to help friends who want to learn by themselves but don't know where to start, and at the same time reduce everyone's burden.Add the business card below to get a full set of learning materials
边栏推荐
猜你喜欢
随机推荐
Sql优化总结!详细!(2021最新面试必问)
The fifth chapter
FCN中制作自己的数据集并进行训练
OpenGL es 导读篇
GCD简单了解
Open Kylin openKylin automation developer platform officially released
SQL——左连接(Left join)、右连接(Right join)、内连接(Inner join)
csdn文件导出为pdf
NowCoderTOP17-22 Binary search/sort - continuous update ing
Centos7 install mysql5.7
NowCoderTOP23-27二叉树遍历——持续更新ing
一些计时软件,生产力工具
如何将虚拟机上的文件复制到主机上
逆置问题--重点
第六章
第二十四课、二十五课,高级光照(blinn),Gamma矫正
Come n times with the sword--05. Replace spaces
尚医通【预约挂号系统】总结
VMware下安装win10启动后进入Boot Manger界面如何解决
SQL存储过程详解