current position:Home>SpringCloud single sign-on
SpringCloud single sign-on
2022-08-06 20:03:25【Lyndon1107】
SpringCloud2021.0.0.5
Single sign-on
Single Sign On, or SSO for short, is one of the more popular solutions for enterprise business integration.The definition of SSO is that in multiple application systems, users only need to log in once to access all mutually trusted application systems.
Operation mechanism
Use a real-life example for comparison.There are many independent attractions in a park, and tourists can buy tickets separately at the entrance of each attraction.For tourists who need to visit all the attractions, this method of buying tickets is very inconvenient, and they need to queue up at the entrance of each attraction to buy tickets.Therefore, most tourists choose to buy a pass (also called a package) at the gate, and they can visit all the attractions without having to buy a new ticket.They only need to show the package they just bought at the entrance of each attraction to be allowed to enter each independent attraction.The same is true for single sign-on.
User Authentication
User authentication: This link is mainly that the user initiates an authentication request to the authentication server, and the authentication server returns a successful token to the user, which is mainly completed in the authentication server, that is, the authentication system in the figure. Note that the authentication system can onlyThere is one.
Identity verification
Identity verification: This part is when the user carries the token to access other servers, the authenticity of the token must be checked in other servers, mainly in the resource server
JWT
JWT (JSON Web Token) is an excellent distributed authentication scheme.
From the distributed authentication process, it is not difficult to find that the most critical role is the token. The security of the token is directly related to the robustness of the system. JWT is used to generate and verify the token.The token can be generated, and the token can also be parsed and verified.
The token generated by JWT consists of three parts:
Header: mainly set some specification information, and the encoding format of the signature part is declared in the header.
Payload: The part of the token that stores valid information, such as username, user role, expiration time, etc., but don't put the password, it will leak!
Signature: After encoding the header and payload in base64, connect them with ".", then add salt, and finally encode with the encoding type declared in the header to get the signature.
Introduction to Asymmetric Encryption RSA Brief
SpringSecurity integrates JWT
1. Analysis of certification ideas
SpringSecurity mainly implements functions through filters!We have to find the filters that SpringSecurity implements authentication and identity verification!
Review of the centralized authentication process
User authentication: Use the attemptAuthentication method in the UsernamePasswordAuthenticationFilter filter to implement the authentication function, and the successfulAuthentication method in the parent class of the filter implements the operation after successful authentication.
Identity verification: Use the doFilterInternal method in the BasicAuthenticationFilter filter to verify whether to log in to determine whether to enter the subsequent filter.
2. Analyze the distributed authentication process
User authentication:
Due to the separation of front and back ends, the project architecture design is distributed. To meet the authentication request parameters that can accept asynchronous post, we need to modify the attemptAuthentication method in the UsernamePasswordAuthenticationFilter filter., so that it can receive the request body.In addition, the default successfulAuthentication method is to put the user information directly into the session after the authentication is passed. Now we need to modify this method to generate a token and return it to the user after the authentication is passed.
Identity verification
Use the doFilterInternal method in the BasicAuthenticationFilter filter to verify whether the user is logged in, just to see if there is user information in the session, we need to modify it to,Verify whether the token carried by the user is legal, parse out the user information, and hand it over to Spring Security, so that the subsequent authorization function can be used normally.
Create Authentication Service
Reference Address
https://blog.csdn.net/xiyang_1990/article/details/124487755
https://blog.csdn.net/CSDN_KONGlX/article/details/125486825
Spring Security + JWT implements a single pointLogin
https://blog.csdn.net/qq_18671415/article/details/118518450
http://t.zoukankan.com/7788IT-p-10693154.html
https://blog.csdn.net/pxg943055021/article/details/124752669
https://blog.csdn.net/wang121213145/article/details/124850518
https://blog.csdn.net/asd747571569/article/details/122511434
copyright notice
author[Lyndon1107],Please bring the original link to reprint, thank you.
https://en.cdmana.com/2022/218/202208061959158792.html
The sidebar is recommended
- Vue family bucket - Vue-CLI2 and Vue-CLI3 hands-on teaching
- [Tips] Mac uses commands to view the size of sub-files or sub-directories in a directory
- Why build an index?
- Descartes set type and what is the effect of quantization coding?
- [Written in the romantic moment of Qixi Lang] The solution for obtaining data when encountering http codes 206 and 302 in Go
- [Operating System] Process Creation and Destruction
- AQS synchronization component - CountDownLatch analysis and case
- Why is there an index in quantization coding?
- What is the linear combination type in quantization coding?
- Arduino Painless Development _LED8*8 Dot Matrix Experiment (Detailed)
guess what you like
element ui table changes the default style, removes the border and changes the table background color
Data Structure ----- Quick Sort
Node.js test SMTP service
Create Nginx docker container reverse proxy https
Python batch get gitlab project code
Do phrases created by the second-class dictionary method have to have a specific meaning?
How do I select the quantitative method for the quantitative characteristics of the coding?
What is the result after straight-sum quantization?
What are the types of high-dimensional indexes?
Back-end writing Swagger interface management documentation
Random recommended
- Windows use Telnet to test smtp
- Docker - way to modify folder mapping
- 10 easy-to-use software on mac
- SSL/TLS protocol operating mechanism in https protocol
- What is the certificate chain of trust for HTTPS?Can't you publish it yourself?
- Nginx error 413 Request Entity Too Large solution
- js data manipulation problem solving?
- After changing the scale of the screen and the ratio of the layout, the Vue project feels very slow to change the transparency of the image?
- Hand in hand with you to get started weback4.0 (1)
- How to pass the data obtained by nodejs to the front desk for use (keyword - system file)
- Chapter 24 How much do you know about proxy knowledge in Spring AOP
- The prize pool experience is bad, very dark
- C + + string container
- RuntimeError: element 0 of tensors does not require grad and does not have a grad_fn
- The vmware virtual machine is disconnected from the network (nat network) after a period of time
- RuntimeError: module compiled against API version 0xa but this version of numpy is 0x9
- Installing vivado2019.1 is always showing "There is no valid Xilinx installation that this Update can be applied to"
- What are the characteristics of the run-length encoding algorithm?
- Question about pygame
- Self-learning crawler encounters a bottleneck, hoping to get some advice
- Webpack5 packaging process source code analysis (1)
- How to understand the memory analysis of executing another method in a JAVA method.
- HTML5 and CSS web material download
- Chapter 215 Aspect-Oriented Programming Spring AOP Actual Configuration
- ASUS laptop software automatically goes to the recycle bin
- Tag attributes you don't know
- usgs download sentinel2
- andriodstudio packaging process without the steps in the tutorial
- msntfs can not be used!
- Chapter XXVIII Aspect-Oriented Programming of AOP Configuration Based on Spring Annotations
- Question about #vsuninstall#, how to solve it?
- Vue + Element tree form implement drag-and-drop sequence
- Are there any abnormal programs that ZTE R5300G4 server will start at 3:00 am every Saturday?Why does this time cause disk exception
- The error "There is no valid Xilinx installation that this Update can be applied to" has been reported when installing vivado2019.1.
- WeChat Mini Program - Simple Diet Recommendation (3)
- Failed to change color in vscode
- Chapter 217 Play Spring5.X Xml configuration conversion to advanced annotation configuration
- Chapter 216 Play with Spring5.X Xml configuration conversion to annotation configuration
- Linux Network Learning Part VII: Detailed Explanation of IP Protocol + Data Link Layer
- Advanced IO for Linux Learning: Five IO Models