In a distributed environment, how to support the PC, APP (iOS, Android) and other multi-terminal session sharing, which is the solution that all companies need, with the traditional session way to solve, I think it is out, we can find a common solution, For example, using traditional CAs to achieve SSO single sign-on between multiple systems or using OAuth for third-party login scenarios? Let's talk about it today. Using Spring Interceptor Interceptor mechanism, JWT authentication method, Redis distributed cache implementation SSO Single Sign-on, gossip less, directly to the steps recorded to share to everyone: distributed architecture
1. Introduction of the relevant jar package for JWT, introduced in Project Pom.xml:
2. Interceptor Configuration:
I've simply configured the URL to intercept and the URL to filter (this depends on your project)
3. Write a JWT encryption or decryption tool class:
This encryption tool class is I find from the Internet, if you want to modify, you can follow your own business changes.
4. Create a Login.java object that is used to encrypt or decrypt JWT:
5. Define the Redislogin object that is used to store the user object through the UID to Redis:
6. Writing Logininterceptor.java Interceptors
7. Define the Loginresponsecode of the exception
8. Write the Unified SSO single Sign-on interface:
9. Test SSO Single Sign-on:
return result set:
Willing to understand the framework of technology or source of friends directly seeking exchange sharing technology: 2042849237
Some of the distributed solutions, the friends who are willing to know can find our team to discuss
More detailed source code reference: Http://minglisoft.cn/technology
Tags: spring,springmvc,spring mvc,web development, Java distributed architecture, SHIRO,MYBATIS,KAFKA,J2EE
Spring+springmvc+interceptor+jwt+redis implementing SSO Single Sign-on