반응형
로그아웃을 처리 해보자 로그인과 별다른건 없다 보안을 위헤서 몇가지 추가 해주면된다.
로그인 컨트롤러 가보자
로그아웃을 가능하게 하려면 현재 로그인되어 있는 유저 객체를 가지고와서 SecurirtContextHolder에 있는 인증객체를 null로 바꾸면 되면된다.
Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); | 현재 로그인 되어 있는 유저 객체를 가지고 온다 |
if ( authentication != null ){ new SecurityContextLogoutHandler().logout(request,response,authentication); } |
인증객체가 널이 아니라면 로그아웃 핸들러를 호출하여 로그아웃 하겠다. |
로그아웃이 완료되면 로그인 페이지로 이동한다
디버그로 로그아웃 되는과정을 보자 간단하다
현재 로그인되어 있는 유저의 인증객체가 확인되고 옆에 사진은 request를 통해서 얻어온 포트 번호 url , get 방식 이렇게 확인할수 있다.
뭐 다른게 없나 싶어서 디버깅을 조금더 깊숙히 들어 가봤지만 마지막엔 결국 session을 가져와서 null처리 해버린다
반응형
'SpringSecurity' 카테고리의 다른 글
SpringSecurity(인증 성공 핸들러) (0) | 2020.12.04 |
---|---|
SpringSecurity(Authentication) 인증 부가기능 (0) | 2020.12.02 |
SpringSecurity( 커스텀 로그인 페이지 생성하기) (0) | 2020.11.25 |
SpringSecurityAuthenticationProvider(DB 연동 인증 처리2) (0) | 2020.11.23 |
SpringSecurity(Form 인증구현) (0) | 2020.11.20 |