Spring Security - Logout API

2021. 4. 15. 11:35SPRING/SPRING SECURITY

사용 예제

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
http
                .logout() // 로그아웃 기능 작동
                .logoutUrl("/logout"//로그아웃 페이지
                .logoutSuccessUrl("/login"// 로그아웃 성공 후 이동할 URL
                .deleteCookies("JSESSIONID""remember-me"// 로그아웃 후 삭제할 쿠키
                .addLogoutHandler(new LogoutHandler() {
                    @Override
                    public void logout(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Authentication authentication) {
                        //로그아웃시 추가적으로 수행할 로직
                    }
                })
                .logoutSuccessHandler(new LogoutSuccessHandler() {
                    @Override
                    public void onLogoutSuccess(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Authentication authentication) throws IOException, ServletException {
                        //로그아웃 성공시 수행할 로직
                    }
                })
                ;
cs