Spring+springmvc+interceptor+jwt+redis implementing SSO Single Sign-on

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.