Spring Security注销GET与POST

时间:2016-08-09 16:43:42

标签: java spring spring-mvc spring-security

我正在使用Spring Boot和Spring Security。我有2个应用程序。他们一起工作。当我想从一个注销时,它也应该从另一个注销。我使用默认的注销流程。在应用程序A上,我单击注销链接:

<logout invalidate-session="true" delete-cookies="JSESSIONID" logout-success-url="/app-b-logout" />

@RequestMapping("/app-b-logout")
public RedirectView appB_Logout() {
    return new RedirectView("http://appB/logout");
}

在应用程序B上,我有以下设置:

.logout().permitAll().logoutUrl("/logout")

退出成功处理程序:

public class MyLogoutSuccessHandler extends AbstractAuthenticationTargetUrlRequestHandler
    implements LogoutSuccessHandler {

@Override
public void onLogoutSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException, ServletException {
   System.out.println(authentication == null); // MAGIC HERE
}

}

在排队System.out.println(authentication == null);中,我有不同的结果。如果我从应用程序A重定向,身份验证为空,当我单击应用程序B上的“注销”按钮(使用帖子表单)时,我有身份验证对象。 但在这两种情况下,用户都会在结果中注销。但我需要用身份验证对象做一些事情。当我从应用A重定向时,如何在应用A上进行重定向以发出POST请求或者如何获得此身份验证?

0 个答案:

没有答案
相关问题