当前位置:网站首页>SSO single sign on implementation.
SSO single sign on implementation.
2022-07-02 00:41:00 【ZZ learn java well】
Login of single architecture : adopt cookie and session The conversational mechanism of .
shortcoming : The server should store login information .
sso Single sign on :
Implementation mode I : Parent domain Cookie
Before we actually implement it , Let's talk about it first Cookie Scope of action .
Cookie The scope of is defined by domain Properties and path Attributes together determine .domain The valid value of property is the domain name of the current domain or its parent domain /IP Address , stay Tomcat in ,domain Property is the domain name of the current domain by default /IP Address .path The valid value of the property is in “/” Path at the beginning , stay Tomcat in ,path Property defaults to current Web Context path of application . If you will Cookie Of domain Property to the parent domain of the current domain , Then think of it as the parent domain Cookie.Cookie There is a feature , In the parent domain Cookie Shared by subdomains , In other words , The child domain automatically inherits from the parent domain Cookie. utilize Cookie This characteristic of , It's not hard to imagine. , take Session ID( or Token) Just save it to the parent domain . you 're right , We just need to put Cookie Of domain Property to the domain name of the parent domain ( The main domain name ), At the same time Cookie Of path Property to the root path , In this way, all sub domain applications can access this Cookie 了 . However, this requires the domain name of the application system to be established under a common primary domain name , Such as tieba.baidu.com and map.baidu.com, They're all built on baidu.com Under the main domain name , Then they can achieve single sign on in this way .
shortcoming :1. The server should centrally store a large amount of login information ( use redis Realization ).
2. To share primary domain .
Implementation mode II : authentication center
Speaking of single sign on , I'm sure I'll see the term :CAS (Central Authentication Service), Now let's talk about it. CAS What happened .
If the login has been extracted as a system separately , We can still play like this . Now we have two systems , Namely www.java3y.com and www.java4y.com, One SSOwww.sso.com

First , Users want to access the system Awww.java3y.com Limited resources ( For example, shopping cart function , The shopping cart function can only be accessed after login ), System Awww.java3y.com Found that the user is not logged in , So redirect to sso authentication center , And take your own address as a parameter . The address of the request is as follows :
www.sso.com?service=www.java3y.com
sso The authentication center found that the user was not logged in , Guide the user to the login page , The user enters the user name and password to log in , The user establishes a global session with the authentication center ( Make a copy of Token, writes Cookie in , Save in browser )

And then , The certification authority redirects back to the system A, And put Token Carry the past to the system A, The redirected address is as follows :
www.java3y.com?token=xxxxxxx
next , System A Go to sso The certification center verifies this Token Whether it is right , If correct , System A Establish a local session with the user ( establish Session)( Can also be Token Store in cookie Inside , Next time you come, just call the method verification of the Certification Center ). Here we are , System A And the user is already logged in .

here , Users want to access the system Bwww.java4y.com Limited resources ( For example, order function , The order function can only be accessed after login ), System Bwww.java4y.com Found that the user is not logged in , So redirect to sso authentication center , And take your own address as a parameter . The address of the request is as follows :
www.sso.com?service=www.java4y.com
Be careful , Because before the user and authentication center www.sso.com A global session has been established ( At that time Cookie Saved to browser ), So this time the system B Redirect to the certification authority www.sso.com Yes, you can Cookie Of .
According to the information brought by the Certification Center Cookie It is found that a global session has been established with the user , The certification authority redirects back to the system B, And put Token Carry the past to the system B, The redirected address is as follows :
www.java4y.com?token=xxxxxxx
next , System B Go to sso The certification center verifies this Token Whether it is right , If correct , System B Establish a local session with the user ( establish Session). Here we are , System B And the user is already logged in .

See here , Actually SSO The certification center is like a transit station .
边栏推荐
- JS -- image to base code, base to file object
- Which app is better and more secure for stock mobile account opening
- 数据分析方法论与前人经验总结【笔记干货】
- sso单点登录的实现。
- [opencv450] hog+svm and hog+cascade for pedestrian detection
- Some understandings of graph convolution neural network r-gcn considering relations and some explanations of DGL official code
- Accelerator systems initiative is an independent non-profit organization
- What is the purpose of ERP project implementation plan?
- 2022 pinduoduo details / pinduoduo product details / pinduoduo SKU details
- Cmake engineering related
猜你喜欢

工作中非常重要的测试策略,你大概没注意过吧

Powerful calendar wechat applet source code - support the main mode of doing more traffic

excel数据透视表

Slf4j print abnormal stack information

JMeter做接口测试,如何提取登录Cookie

Take the enclave Park as a sample to see how Yuhua and Shaoshan play the song of Chang Zhu Tan integrated development

数据分析方法论与前人经验总结【笔记干货】

Mysql database driver (JDBC Driver) jar package download

Intelligent operation and maintenance practice: banking business process and single transaction tracking

Leetcode skimming: stack and queue 04 (delete all adjacent duplicates in the string)
随机推荐
To meet the needs of consumers in technological upgrading, Angel water purifier's competitive way of "value war"
New version of free mobile phone, PC, tablet, notebook four terminal Website thumbnail display diagram online one click to generate website source code
PWN attack and defense world cgpwn2
Picture puzzle wechat applet source code_ Support multi template production and traffic master
If the browser is accidentally closed, how does react cache the forms filled out by users?
Comprehensive usage and case questions of sub query of SQL data analysis [patient sorting]
The origin of usb-if Association and various interfaces
启牛商学院给的证券账户安不安全?哪里可以开户
【opencv】train&test HOG+SVM
excel数据透视表
4. Object mapping Mapstercover
AIX存储管理之卷组的创建(一)
Otaku wallpaper Daquan wechat applet source code - with dynamic wallpaper to support a variety of traffic owners
From 20s to 500ms, I used these three methods
【微信授权登录】uniapp开发小程序,实现获取微信授权登录功能
【底部弹出-选择器】uniapp Picker组件——底部弹起的滚动选择器
The 8-year salary change of testers makes netizens envy it: you pay me one year's salary per month
Kuberntes cloud native combat high availability deployment architecture
Accelerator systems initiative is an independent non-profit organization
Export default the exported object cannot be deconstructed, and module Differences between exports