1

i am using spring security for authentication and if i have 2 servers (server1, server2) using the same file war.

the User A make login in server 1, saving data on persistent_logins table. If the user A makes refresh on server 2, is automatically logged. This is correct but if the u*ser A (server1)* makes logout, the data of table persistent_logins is removed and the user A(server 2) when makes refresh, still connect.

What i can do to user A(server 2) change to logout mode?

thanks

Vítor Nóbrega
  • 1,219
  • 4
  • 26
  • 53

2 Answers2

2

If you know how to catch the moment when you need to make user_A log out, you may consider using filters and clearing the current session.

public void doFilter(ServletRequest request, ServletResponse response,
        FilterChain chain) throws IOException, ServletException {
    // skip non-http requests
    if (!(request instanceof HttpServletRequest)) {
        chain.doFilter(request, response);
        return;
    }

    HttpServletRequest httpRequest = (HttpServletRequest) request;
    httpRequest.getSession().invalidate();
    ...

If you need to inject some beans using spring, you may have a look at DelegatingFilterProxy

Alexey Grigorev
  • 2,415
  • 28
  • 47
1

The easiest solution update data on both server when user logout

nidhin
  • 6,661
  • 6
  • 32
  • 50