Get the App
SLTechnology News&Howtos  ›  Development  › 

How to parse the implementation of single sign-on under the same domain of springsession

Shulou Source: shulou.com Published: 2022-06-02 06:15:46 09月19日 Update

What this article shares with you is about how to analyze the single sign-on implementation in the same domain of springsession. The editor thinks it is very practical, so I share it with you to learn. I hope you can get something after reading this article. Let's take a look at it.

Session session Management

In Web project development, Session session management is a very important part, which is used to store and record user status or related data. Usually, session is entrusted to the container (tomcat) for storage and management, but if the project is deployed in multiple tomcat, there are great problems with session management.

1. Session cannot be shared among multiple tomcat. For example, the user has logged in on the tomcat A server, but when the load balancer jumps to tomcat B, the session expires because the tomcat B server does not have the user's login information, and the user logs out.

2. Once the tomcat container is closed or restarted, the session session will also become invalid; therefore, if the project is deployed in multiple tomcat, the problem of session sharing needs to be solved.

Configuration file

Pom.xml

Org.springframework.session

Spring-session-data-redis

1.3.1.RELEASE

Web.xml

SpringSessionRepositoryFilter

Org.springframework.web.filter.DelegatingFilterProxy

SpringSessionRepositoryFilter

* .do

Org.springframework.web.context.ContextLoaderListener

ContextConfigLocation

Classpath:applicationContext.xml

ApplicationContext.xml

Code testing

Public class SessionServlet extends HttpServlet {

Protected void doPost (HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {this.doGet (request,response)

} protected void doGet (HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {String sesssionID = request.getSession () .getId ()

/ / deploy two copies and change this place from 8081 to 8080, just to distinguish between response.getWriter (). Write ("8081 Server SessionID" + sesssionID);}}

The above is how to parse the implementation of single sign-on in the same domain of springsession. The editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.

Tags: Login user management multiple project container more server knowledge article section problem storage service practical big important balanced between code Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS Shulou Technology vpn MariaDB Redmi