게시글
질문&답변
동시세션제어 기능에서 로그아웃하기
다시보니 강사님께서 이미 답변하신 내용이네요 ^^ https://www.inflearn.com/community/questions/40072/동시-세션-제어-동일-브라우저에서-로그아웃이-정책-미적용
- 0
- 3
- 67
질문&답변
동시세션제어 기능에서 로그아웃하기
@GetMapping(value = "/api/logout") public String logout(HttpServletRequest request, HttpServletResponse response) { Authentication authentication = SecurityContextHolder.getContextHolderStrategy().getContext().getAuthentication(); if (authentication != null) { new SecurityContextLogoutHandler().logout(request, response, authentication); } return "logout"; }위 코드를 사용합니다.잠시 구글링을 해보니@Bean public static ServletListenerRegistrationBean httpSessionEventPublisher() { return new ServletListenerRegistrationBean(new HttpSessionEventPublisher()); }이렇게 HttpSessionEventPublisher를 등록하면 SeesionRegistry가 이벤트를 감지하여 onApplicationEvent()에서 removeSessionInformation()을 호출한다고 하여 테스트 해보니 로그아웃시 잘 동작하네요
- 0
- 3
- 67